]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: touch nexthop handling code
authorDenis Ovsienko <infrastation@yandex.ru>
Fri, 5 Aug 2011 14:52:52 +0000 (18:52 +0400)
committerDenis Ovsienko <infrastation@yandex.ru>
Fri, 5 Aug 2011 14:52:52 +0000 (18:52 +0400)
bgp_nexthop_lookup_ipv6(): declare variables where they are actually
used, drop no-op initialization (the field is already 0)
bgp_nexthop_lookup(): ditto
bgp_nexthop_check_ebgp(): rename to bgp_nexthop_onlink()
bgp_nexthop_cache_changed(): rename to bgp_nexthop_cache_different()

bgpd/bgp_nexthop.c
bgpd/bgp_nexthop.h
bgpd/bgp_route.c

index 0cde665eb380e4d2585d3d8595d7a41b249d30ca..de303e345f6a46ae88ed225263b385226a696353 100644 (file)
@@ -146,7 +146,7 @@ bgp_nexthop_same (struct nexthop *next1, struct nexthop *next2)
 }
 
 static int
-bgp_nexthop_cache_changed (struct bgp_nexthop_cache *bnc1,
+bgp_nexthop_cache_different (struct bgp_nexthop_cache *bnc1,
                           struct bgp_nexthop_cache *bnc2)
 {
   int i;
@@ -171,7 +171,7 @@ bgp_nexthop_cache_changed (struct bgp_nexthop_cache *bnc1,
 
 /* If nexthop exists on connected network return 1. */
 int
-bgp_nexthop_check_ebgp (afi_t afi, struct attr *attr)
+bgp_nexthop_onlink (afi_t afi, struct attr *attr)
 {
   struct bgp_node *rn;
 
@@ -256,12 +256,11 @@ bgp_nexthop_lookup_ipv6 (struct peer *peer, struct bgp_info *ri, int *changed,
       bnc = zlookup_query_ipv6 (&attr->extra->mp_nexthop_global);
       if (bnc)
        {
-         struct bgp_table *old;
-         struct bgp_node *oldrn;
-         struct bgp_nexthop_cache *oldbnc;
-
          if (changed)
            {
+             struct bgp_table *old;
+             struct bgp_node *oldrn;
+
              if (bgp_nexthop_cache_table[AFI_IP6] == cache1_table[AFI_IP6])
                old = cache2_table[AFI_IP6];
              else
@@ -270,9 +269,9 @@ bgp_nexthop_lookup_ipv6 (struct peer *peer, struct bgp_info *ri, int *changed,
              oldrn = bgp_node_lookup (old, &p);
              if (oldrn)
                {
-                 oldbnc = oldrn->info;
+                 struct bgp_nexthop_cache *oldbnc = oldrn->info;
 
-                 bnc->changed = bgp_nexthop_cache_changed (bnc, oldbnc);
+                 bnc->changed = bgp_nexthop_cache_different (bnc, oldbnc);
 
                  if (bnc->metric != oldbnc->metric)
                    bnc->metricchanged = 1;
@@ -282,7 +281,6 @@ bgp_nexthop_lookup_ipv6 (struct peer *peer, struct bgp_info *ri, int *changed,
       else
        {
          bnc = bnc_new ();
-         bnc->valid = 0;
        }
       rn->info = bnc;
     }
@@ -345,12 +343,11 @@ bgp_nexthop_lookup (afi_t afi, struct peer *peer, struct bgp_info *ri,
       bnc = zlookup_query (addr);
       if (bnc)
        {
-         struct bgp_table *old;
-         struct bgp_node *oldrn;
-         struct bgp_nexthop_cache *oldbnc;
-
          if (changed)
            {
+             struct bgp_table *old;
+             struct bgp_node *oldrn;
+
              if (bgp_nexthop_cache_table[AFI_IP] == cache1_table[AFI_IP])
                old = cache2_table[AFI_IP];
              else
@@ -359,9 +356,9 @@ bgp_nexthop_lookup (afi_t afi, struct peer *peer, struct bgp_info *ri,
              oldrn = bgp_node_lookup (old, &p);
              if (oldrn)
                {
-                 oldbnc = oldrn->info;
+                 struct bgp_nexthop_cache *oldbnc = oldrn->info;
 
-                 bnc->changed = bgp_nexthop_cache_changed (bnc, oldbnc);
+                 bnc->changed = bgp_nexthop_cache_different (bnc, oldbnc);
 
                  if (bnc->metric != oldbnc->metric)
                    bnc->metricchanged = 1;
@@ -371,7 +368,6 @@ bgp_nexthop_lookup (afi_t afi, struct peer *peer, struct bgp_info *ri,
       else
        {
          bnc = bnc_new ();
-         bnc->valid = 0;
        }
       rn->info = bnc;
     }
@@ -458,7 +454,7 @@ bgp_scan (afi_t afi, safi_t safi)
              metricchanged = 0;
 
              if (peer_sort (bi->peer) == BGP_PEER_EBGP && bi->peer->ttl == 1)
-               valid = bgp_nexthop_check_ebgp (afi, bi->attr);
+               valid = bgp_nexthop_onlink (afi, bi->attr);
              else
                valid = bgp_nexthop_lookup (afi, bi->peer, bi,
                                            &changed, &metricchanged);
index 2dad742ff424b473d15aed706d6200847a92a5a0..874f3bba0d96166ad097aaefca2a1588f1f0e52f 100644 (file)
@@ -54,7 +54,7 @@ extern void bgp_connected_add (struct connected *c);
 extern void bgp_connected_delete (struct connected *c);
 extern int bgp_multiaccess_check_v4 (struct in_addr, char *);
 extern int bgp_config_write_scan_time (struct vty *);
-extern int bgp_nexthop_check_ebgp (afi_t, struct attr *);
+extern int bgp_nexthop_onlink (afi_t, struct attr *);
 extern int bgp_nexthop_self (afi_t, struct attr *);
 
 #endif /* _QUAGGA_BGP_NEXTHOP_H */
index de1c000f6070c7d81b275a38cefa633b1dc31db1..cf8e21135dd6e39d29c14e6532a6cd552f956baf 100644 (file)
@@ -2064,7 +2064,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
       /* If the peer is EBGP and nexthop is not on connected route,
         discard it.  */
       if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1
-         && ! bgp_nexthop_check_ebgp (afi, &new_attr)
+         && ! bgp_nexthop_onlink (afi, &new_attr)
          && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
        {
          reason = "non-connected next-hop;";