[PATCH] Don't set the preference when the default router lifetime is zero

Baptiste Jonglez bjonglez at illyse.org
Mon Jul 7 17:20:29 CEST 2014


This is a MUST from RFC 4191.
---
 proto/radv/packets.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/proto/radv/packets.c b/proto/radv/packets.c
index ae877f5..51eb80c 100644
--- a/proto/radv/packets.c
+++ b/proto/radv/packets.c
@@ -251,11 +251,11 @@ radv_prepare_ra(struct radv_iface *ifa)
   pkt->code = 0;
   pkt->checksum = 0;
   pkt->current_hop_limit = ic->current_hop_limit;
-  pkt->flags = (ic->managed ? OPT_RA_MANAGED : 0) |
-    (ic->other_config ? OPT_RA_OTHER_CFG : 0) |
-    ic->default_preference;
   pkt->router_lifetime = (ra->active || !ic->default_lifetime_sensitive) ?
     htons(ic->default_lifetime) : 0;
+  pkt->flags = (ic->managed ? OPT_RA_MANAGED : 0) |
+    (ic->other_config ? OPT_RA_OTHER_CFG : 0) |
+    (pkt->router_lifetime ? ic->default_preference : 0);
   pkt->reachable_time = htonl(ic->reachable_time);
   pkt->retrans_timer = htonl(ic->retrans_timer);
   buf += sizeof(*pkt);
@@ -335,6 +335,9 @@ radv_send_ra(struct radv_iface *ifa, int shutdown)
        we suppose that the iface will be removed */
     struct radv_ra_packet *pkt = (void *) ifa->sk->tbuf;
     pkt->router_lifetime = 0;
+    /* Quoting RFC 4191: "If the Router Lifetime is zero, the preference
+       value MUST be set to (00) by the sender". */
+    pkt->flags &= 0b11100111;
   }
 
   RADV_TRACE(D_PACKETS, "Sending RA via %s", ifa->iface->name);
-- 
2.0.0




More information about the Bird-users mailing list