missing RTMGRP_***_ROUTE notifications on ifdown

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




hi,


I noticed by chance that taking down a network interface does not trigger notifications to RTMGRP_IPV4_ROUTE as well.
here is a simple copy-paste patch against fib_hash.c to fix that. I didn't check IPv6 very carefully, but it seems that
something similar would need to be added to fib6_ifdown as well.

cheers,
John.


--- net/ipv4/fib_hash.c.orig	2004-02-17 11:22:15.000000000 +0100
+++ net/ipv4/fib_hash.c	2004-02-17 16:40:02.000000000 +0100
@@ -726,10 +726,12 @@
 }
 
 static __inline__ int
-fn_flush_list(struct fib_node ** fp, int z, struct fn_hash *table)
+fn_flush_list(struct fib_node ** fp, int z, struct fib_table *tb)
 {
 	int found = 0;
 	struct fib_node *f;
+	struct sk_buff *skb;
+	int size = NLMSG_SPACE(sizeof(struct rtmsg)+256);
 
 	while ((f = *fp) != NULL) {
 		struct fib_info *fi = FIB_INFO(f);
@@ -738,7 +740,27 @@
 			write_lock_bh(&fib_hash_lock);
 			*fp = f->fn_next;
 			write_unlock_bh(&fib_hash_lock);
-
+			/* quick and dirty fix: one message per route */
+			skb = alloc_skb(size, GFP_KERNEL);
+			if (!skb)
+				goto free_node;		/* notification will be lost (with no
+									 * chance to learn what it was)
+									 * possible solution: a pre-allocated
+									 * skb for emergency notifications
+									 */
+			fib_dump_info(	skb,
+					0,	//pid
+					0,	//seqno,
+					RTM_DELROUTE,
+					tb->tb_id,
+					(f->fn_state&FN_S_ZOMBIE) ? 0 : f->fn_type,
+					f->fn_scope,
+					&f->fn_key,
+					z,
+					f->fn_tos,
+					f->fn_info);
+			netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV4_ROUTE, GFP_KERNEL);
+free_node:
 			fn_free_node(f);
 			found++;
 			continue;
@@ -759,7 +781,7 @@
 		int i;
 		int tmp = 0;
 		for (i=fz->fz_divisor-1; i>=0; i--)
-			tmp += fn_flush_list(&fz->fz_hash[i], fz->fz_order, table);
+			tmp += fn_flush_list(&fz->fz_hash[i], fz->fz_order, tb);
 		fz->fz_nent -= tmp;
 		found += tmp;
 	}


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux