[PATCH 1/9] netlink: Fix up link down behaviour

Ian Jackson ijackson at chiark.greenend.org.uk
Wed Jul 11 01:09:58 BST 2012


Partially reverts 04f92904ea6c41517ff7154910c16ef4c3bc646b
 "userv-ipif: Always request routes from userv, regardless of link quality"

It turns out that this check is necessary to avoid bringing up a route
for a "netlink" stanza in the configuration file which is never used.

In particular, this avoids bringing up a netlink for (a) sites which
are not mentioned in the config file (b) the site on which secnet is
running.

Signed-off-by: Ian Jackson <ijackson at chiark.greenend.org.uk>
---
 netlink.c |    2 +-
 secnet.h  |    9 +++++----
 slip.c    |   12 +++++++-----
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/netlink.c b/netlink.c
index 5226ad1..df51d9c 100644
--- a/netlink.c
+++ b/netlink.c
@@ -909,7 +909,7 @@ static closure_t *netlink_inst_create(struct netlink *st,
     c->deliver=NULL;
     c->dst=NULL;
     c->name=name;
-    c->link_quality=LINK_QUALITY_DOWN;
+    c->link_quality=LINK_QUALITY_UNUSED;
     c->mtu=mtu?mtu:st->mtu;
     c->options=options;
     c->outcount=0;
diff --git a/secnet.h b/secnet.h
index 06beb05..ecbb995 100644
--- a/secnet.h
+++ b/secnet.h
@@ -420,10 +420,11 @@ struct transform_if {
 typedef void netlink_deliver_fn(void *st, struct buffer_if *buf);
 /* site code can tell netlink when outgoing packets will be dropped,
    so netlink can generate appropriate ICMP and make routing decisions */
-#define LINK_QUALITY_DOWN 0   /* No chance of a packet being delivered */
-#define LINK_QUALITY_DOWN_STALE_ADDRESS 1 /* Link down, old address information */
-#define LINK_QUALITY_DOWN_CURRENT_ADDRESS 2 /* Link down, current address information */
-#define LINK_QUALITY_UP 3     /* Link active */
+#define LINK_QUALITY_UNUSED 0   /* This link is unused, do not make this netlink */
+#define LINK_QUALITY_DOWN 1   /* No chance of a packet being delivered right away*/
+#define LINK_QUALITY_DOWN_STALE_ADDRESS 2 /* Link down, old address information */
+#define LINK_QUALITY_DOWN_CURRENT_ADDRESS 3 /* Link down, current address information */
+#define LINK_QUALITY_UP 4     /* Link active */
 #define MAXIMUM_LINK_QUALITY 3
 typedef void netlink_link_quality_fn(void *st, uint32_t quality);
 typedef void netlink_register_fn(void *st, netlink_deliver_fn *deliver,
diff --git a/slip.c b/slip.c
index 7c138d1..db89a27 100644
--- a/slip.c
+++ b/slip.c
@@ -257,11 +257,13 @@ static void userv_invoke_userv(struct userv *st)
 
     allnets=ipset_new();
     for (r=st->slip.nl.clients; r; r=r->next) {
-	struct ipset *nan;
-	r->kup=True;
-	nan=ipset_union(allnets,r->networks);
-	ipset_free(allnets);
-	allnets=nan;
+	if (r->link_quality > LINK_QUALITY_UNUSED) {
+	    struct ipset *nan;
+	    r->kup=True;
+	    nan=ipset_union(allnets,r->networks);
+	    ipset_free(allnets);
+	    allnets=nan;
+	}
     }
     snets=ipset_to_subnet_list(allnets);
     ipset_free(allnets);
-- 
1.7.2.5




More information about the sgo-software-discuss mailing list