[quagga-dev 11974] [PATCH] bgpd: Deprecate 'neighbour ... interface', replace peer->interface with update_if

Paul Jakma paul at opensourcerouting.org
Fri Jan 23 16:39:21 GMT 2015


* The 'neighbour ... interface' command has been deprecated since 2006.
  Get rid of the underlying peer->ifname field, DEFUN_DEPRECATE the command,
  and make the command just set the update-source interface name.
  I.e. 'neighbour ... interface <ifname>' now does
  'neighbour ... update-source <ifname>' and will try bind the session to the
  given interface, if configured..

* bgp_network.c: (bgp_bind) Use the update-source update_if interface name
  to bind to, if configured.
  (bgp_connect) Use the update_if to connect to, matters primarily for
  IPv6 link-local address peer.
* bgp_vty.c: (neighbor_interface) Deprecate.
* bgp_zebra: (bgp_{nexthop_set,zebra_{announce,withdraw}}) replace peer->ifname
  with peer->update_if
---
 bgpd/bgp_network.c | 10 +++++-----
 bgpd/bgp_vty.c     |  4 ++--
 bgpd/bgp_zebra.c   | 12 ++++++------
 bgpd/bgpd.c        | 15 ++-------------
 bgpd/bgpd.h        |  3 +--
 doc/bgpd.texi      | 18 +++++++++---------
 6 files changed, 25 insertions(+), 37 deletions(-)

diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index c052744..8e6c372 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -277,10 +277,10 @@ bgp_bind (struct peer *peer)
   int ret;
   struct ifreq ifreq;
 
-  if (! peer->ifname)
+  if (! peer->update_if)
     return 0;
 
-  strncpy ((char *)&ifreq.ifr_name, peer->ifname, sizeof (ifreq.ifr_name));
+  strncpy ((char *)&ifreq.ifr_name, peer->update_if, sizeof (ifreq.ifr_name));
 
   if ( bgpd_privs.change (ZPRIVS_RAISE) )
   	zlog_err ("bgp_bind: could not raise privs");
@@ -293,7 +293,7 @@ bgp_bind (struct peer *peer)
 
   if (ret < 0)
     {
-      zlog (peer->log, LOG_INFO, "bind to interface %s failed", peer->ifname);
+      zlog (peer->log, LOG_INFO, "bind to interface %s failed", peer->update_if);
       return ret;
     }
 #endif /* SO_BINDTODEVICE */
@@ -402,8 +402,8 @@ bgp_connect (struct peer *peer)
   bgp_update_source (peer);
 
 #ifdef HAVE_IPV6
-  if (peer->ifname)
-    ifindex = if_nametoindex (peer->ifname);
+  if (peer->update_if)
+    ifindex = if_nametoindex (peer->update_if);
 #endif /* HAVE_IPV6 */
 
   if (BGP_DEBUG (events, EVENTS))
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index ca44774..94eda40 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -3497,7 +3497,7 @@ peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
   return bgp_vty_return (vty, ret);
 }
 
-DEFUN (neighbor_interface,
+DEFUN_DEPRECATED (neighbor_interface,
        neighbor_interface_cmd,
        NEIGHBOR_CMD "interface WORD",
        NEIGHBOR_STR
@@ -3508,7 +3508,7 @@ DEFUN (neighbor_interface,
   return peer_interface_vty (vty, argv[0], argv[1]);
 }
 
-DEFUN (no_neighbor_interface,
+DEFUN_DEPRECATED (no_neighbor_interface,
        no_neighbor_interface_cmd,
        NO_NEIGHBOR_CMD "interface WORD",
        NO_STR
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index f18d916..9204a57 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -571,8 +571,8 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote,
     {
       if (IN6_IS_ADDR_LINKLOCAL (&local->sin6.sin6_addr))
 	{
-	  if (peer->ifname)
-	    ifp = if_lookup_by_index (if_nametoindex (peer->ifname));
+	  if (peer->update_if)
+	    ifp = if_lookup_by_index (if_nametoindex (peer->update_if));
 	}
       else
 	ifp = if_lookup_by_ipv6 (&local->sin6.sin6_addr);
@@ -791,8 +791,8 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp, sa
 
       if (IN6_IS_ADDR_LINKLOCAL (nexthop) && ! ifindex)
 	{
-	  if (info->peer->ifname)
-	    ifindex = if_nametoindex (info->peer->ifname);
+	  if (info->peer->update_if)
+	    ifindex = if_nametoindex (info->peer->update_if);
 	  else if (info->peer->nexthop.ifp)
 	    ifindex = info->peer->nexthop.ifp->ifindex;
 	}
@@ -912,8 +912,8 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi)
 	return;
 
       if (IN6_IS_ADDR_LINKLOCAL (nexthop) && ! ifindex)
-	if (info->peer->ifname)
-	  ifindex = if_nametoindex (info->peer->ifname);
+	if (info->peer->update_if)
+	  ifindex = if_nametoindex (info->peer->update_if);
 
       api.flags = flags;
       api.type = ZEBRA_ROUTE_BGP;
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index b006597..c6c7c18 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -3349,20 +3349,14 @@ peer_advertise_interval_unset (struct peer *peer)
 int
 peer_interface_set (struct peer *peer, const char *str)
 {
-  if (peer->ifname)
-    free (peer->ifname);
-  peer->ifname = strdup (str);
-
+  peer_update_source_if_set (peer, str);
   return 0;
 }
 
 int
 peer_interface_unset (struct peer *peer)
 {
-  if (peer->ifname)
-    free (peer->ifname);
-  peer->ifname = NULL;
-
+  peer_update_source_unset (peer);
   return 0;
 }
 
@@ -4842,11 +4836,6 @@ bgp_config_write_peer (struct vty *vty, struct bgp *bgp,
 	vty_out (vty, " neighbor %s port %d%s", addr, peer->port,
 		 VTY_NEWLINE);
 
-      /* Local interface name. */
-      if (peer->ifname)
-	vty_out (vty, " neighbor %s interface %s%s", addr, peer->ifname,
-		 VTY_NEWLINE);
-  
       /* Passive. */
       if (CHECK_FLAG (peer->flags, PEER_FLAG_PASSIVE))
         if (! peer_group_active (peer) ||
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 8cfb81b..85a3c12 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -339,8 +339,7 @@ struct peer
   time_t resettime;		/* Last reset time */
   
   unsigned int ifindex;		/* ifindex of the BGP connection. */
-  char *ifname;			/* bind interface name. */
-  char *update_if;
+  char *update_if;		/* bind interface name. */
   union sockunion *update_source;
   struct zlog *log;
 
diff --git a/doc/bgpd.texi b/doc/bgpd.texi
index 7d92b5e..ed903ca 100644
--- a/doc/bgpd.texi
+++ b/doc/bgpd.texi
@@ -290,11 +290,6 @@ version.
 
 @deffn {BGP} {neighbor @var{peer} interface @var{ifname}} {}
 @deffnx {BGP} {no neighbor @var{peer} interface @var{ifname}} {}
-When you connect to a BGP peer over an IPv6 link-local address, you 
-have to specify the @var{ifname} of the interface used for the 
-connection. To specify IPv4 session addresses, see the 
- at code{neighbor @var{peer} update-source} command below.
-
 This command is deprecated and may be removed in a future release. Its
 use should be avoided.
 @end deffn
@@ -309,10 +304,15 @@ also for routes learned via iBGP.
 
 @deffn {BGP} {neighbor @var{peer} update-source @var{<ifname|address>}} {}
 @deffnx {BGP} {no neighbor @var{peer} update-source} {}
-Specify the IPv4 source address to use for the @acronym{BGP} session to this
-neighbour, may be specified as either an IPv4 address directly or
-as an interface name (in which case the @command{zebra} daemon MUST be running
-in order for @command{bgpd} to be able to retrieve interface state).
+Specify the source address to use for the @acronym{BGP} session
+to this neighbour.  It may be specified as either an IP address or as an
+interface name (in which case the @command{zebra} daemon MUST be running in
+order for @command{bgpd} to be able to retrieve interface state). 
+
+To connect to a @acronym{BGP} peer over an IPv6 link-local address,
+you MUST use this command to specify the @var{ifname} of the interface used
+for the connection. The @command{zebra} daemon MUST be running.
+
 @example
 @group
 router bgp 64555
-- 
2.1.0





More information about the Quagga-dev mailing list