]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: justify checks for IPv4 class D/E
authorDenis Ovsienko <infrastation@yandex.ru>
Sat, 17 Dec 2011 15:39:30 +0000 (19:39 +0400)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 2 Jan 2012 13:27:34 +0000 (17:27 +0400)
* lib/prefix.h
  * IPV4_CLASS_DE(): make consistent with counterpart macros
* bgp_packet.c
  * bgp_open_receive(): test using macro instead of ">="
* bgp_route.c
  * bgp_update_rsclient(): idem
  * bgp_update_main(): idem

bgpd/bgp_packet.c
bgpd/bgp_route.c
lib/prefix.h

index 5f150600df685e78b8a39046e006fa1628468ac9..fc653e2176502e15f735c833d63df8a60d10b2b0 100644 (file)
@@ -1387,7 +1387,7 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
 
   /* remote router-id check. */
   if (remote_id.s_addr == 0
-      || ntohl (remote_id.s_addr) >= 0xe0000000
+      || IPV4_CLASS_DE (ntohl (remote_id.s_addr))
       || ntohl (peer->local_id.s_addr) == ntohl (remote_id.s_addr))
     {
       if (BGP_DEBUG (normal, NORMAL))
index 98e49bcdc35e118857efa03dc4a98ef17629158b..189929a0ddfba4452507d8cc6e133ddb9c410f8c 100644 (file)
@@ -1815,9 +1815,9 @@ bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
   /* IPv4 unicast next hop check.  */
   if (afi == AFI_IP && safi == SAFI_UNICAST)
     {
-     /* Next hop must not be 0.0.0.0 nor Class E address. */
+     /* Next hop must not be 0.0.0.0 nor Class D/E address. */
       if (new_attr.nexthop.s_addr == 0
-         || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000)
+         || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)))
        {
          bgp_attr_unintern (attr_new);
 
@@ -2071,11 +2071,11 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
          goto filtered;
        }
 
-      /* Next hop must not be 0.0.0.0 nor Class E address.  Next hop
+      /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop
         must not be my own address.  */
       if (bgp_nexthop_self (afi, &new_attr)
          || new_attr.nexthop.s_addr == 0
-         || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000)
+         || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)))
        {
          reason = "martian next-hop;";
          goto filtered;
index 12c0d07e2386ddeec7b80cdd9dcd928b68c9ba0a..dab4202ea817a6780f65151f8d3826d87828edbf 100644 (file)
@@ -112,7 +112,7 @@ struct prefix_rd
 #define IPV4_NET0(a)    ((((u_int32_t) (a)) & 0xff000000) == 0x00000000)
 #define IPV4_NET127(a)  ((((u_int32_t) (a)) & 0xff000000) == 0x7f000000)
 #define IPV4_LINKLOCAL(a) ((((u_int32_t) (a)) & 0xffff0000) == 0xa9fe0000)
-#define IPV4_CLASS_DE(a) ((u_int32_t) (a) >= 0xe0000000)
+#define IPV4_CLASS_DE(a)  ((((u_int32_t) (a)) & 0xe0000000) == 0xe0000000)
 
 /* Max bit/byte length of IPv6 address. */
 #define IPV6_MAX_BYTELEN    16