diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-12-02 20:02:06 +0100 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-12-02 20:02:06 +0100 |
commit | 0b11464604990198553c451e8c0bf830a44adcf1 (patch) | |
tree | bea0c1aca92b0e1f2277fc887b926c1719cf0f56 /zebra | |
parent | bgpd: Add missing argv handler for ipv4 prefix in `show...vpnv4` cmd (diff) | |
parent | lib: Macroize CLI matcher tracing (diff) | |
download | frr-0b11464604990198553c451e8c0bf830a44adcf1.tar.xz frr-0b11464604990198553c451e8c0bf830a44adcf1.zip |
Merge remote-tracking branch 'osr_private_quagga/queue/osr/vtysh-generic' into vtysh-grammar
Diffstat (limited to 'zebra')
-rw-r--r-- | zebra/if_ioctl.c | 134 | ||||
-rw-r--r-- | zebra/interface.c | 43 | ||||
-rw-r--r-- | zebra/kernel_socket.c | 1 | ||||
-rw-r--r-- | zebra/rt_socket.c | 1 | ||||
-rw-r--r-- | zebra/zebra_mpls.c | 1 | ||||
-rw-r--r-- | zebra/zebra_mpls_netlink.c | 21 | ||||
-rw-r--r-- | zebra/zebra_mpls_null.c | 21 | ||||
-rw-r--r-- | zebra/zebra_mpls_openbsd.c | 21 | ||||
-rw-r--r-- | zebra/zebra_rib.c | 1 | ||||
-rw-r--r-- | zebra/zebra_rnh.c | 1 | ||||
-rw-r--r-- | zebra/zebra_snmp.c | 4 |
11 files changed, 74 insertions, 175 deletions
diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c index 5b7b5863e..cc348fc23 100644 --- a/zebra/if_ioctl.c +++ b/zebra/if_ioctl.c @@ -36,6 +36,8 @@ #include "zebra/interface.h" #include "zebra/rib.h" +#include <ifaddrs.h> + /* Interface looking up using infamous SIOCGIFCONF. */ static int interface_list_ioctl (void) @@ -138,44 +140,7 @@ interface_list_ioctl (void) static int if_get_index (struct interface *ifp) { -#if defined(HAVE_IF_NAMETOINDEX) - /* Modern systems should have if_nametoindex(3). */ ifp->ifindex = if_nametoindex(ifp->name); -#elif defined(SIOCGIFINDEX) && !defined(HAVE_BROKEN_ALIASES) - /* Fall-back for older linuxes. */ - int ret; - struct ifreq ifreq; - static int if_fake_index; - - ifreq_set_name (&ifreq, ifp); - - ret = if_ioctl (SIOCGIFINDEX, (caddr_t) &ifreq); - if (ret < 0) - { - /* Linux 2.0.X does not have interface index. */ - ifp->ifindex = if_fake_index++; - return ifp->ifindex; - } - - /* OK we got interface index. */ -#ifdef ifr_ifindex - ifp->ifindex = ifreq.ifr_ifindex; -#else - ifp->ifindex = ifreq.ifr_index; -#endif - -#else -/* Linux 2.2.X does not provide individual interface index - for aliases and we know it. For others issue a warning. */ -#if !defined(HAVE_BROKEN_ALIASES) -#warning "Using if_fake_index. You may want to add appropriate" -#warning "mapping from ifname to ifindex for your system..." -#endif - /* This branch probably won't provide usable results, but anyway... */ - static int if_fake_index = 1; - ifp->ifindex = if_fake_index++; -#endif - return ifp->ifindex; } @@ -211,9 +176,6 @@ if_get_hwaddr (struct interface *ifp) } #endif /* SIOCGIFHWADDR */ -#ifdef HAVE_GETIFADDRS -#include <ifaddrs.h> - static int if_getaddrs (void) { @@ -334,93 +296,6 @@ if_getaddrs (void) return 0; } -#else /* HAVE_GETIFADDRS */ -/* Interface address lookup by ioctl. This function only looks up - IPv4 address. */ -int -if_get_addr (struct interface *ifp) -{ - int ret; - struct ifreq ifreq; - struct sockaddr_in addr; - struct sockaddr_in mask; - struct sockaddr_in dest; - struct in_addr *dest_pnt; - u_char prefixlen; - int flags = 0; - - /* Interface's name and address family. */ - strncpy (ifreq.ifr_name, ifp->name, IFNAMSIZ); - ifreq.ifr_addr.sa_family = AF_INET; - - /* Interface's address. */ - ret = if_ioctl (SIOCGIFADDR, (caddr_t) &ifreq); - if (ret < 0) - { - if (errno != EADDRNOTAVAIL) - { - zlog_warn ("SIOCGIFADDR fail: %s", safe_strerror (errno)); - return ret; - } - return 0; - } - memcpy (&addr, &ifreq.ifr_addr, sizeof (struct sockaddr_in)); - - /* Interface's network mask. */ - ret = if_ioctl (SIOCGIFNETMASK, (caddr_t) &ifreq); - if (ret < 0) - { - if (errno != EADDRNOTAVAIL) - { - zlog_warn ("SIOCGIFNETMASK fail: %s", safe_strerror (errno)); - return ret; - } - return 0; - } -#ifdef ifr_netmask - memcpy (&mask, &ifreq.ifr_netmask, sizeof (struct sockaddr_in)); -#else - memcpy (&mask, &ifreq.ifr_addr, sizeof (struct sockaddr_in)); -#endif /* ifr_netmask */ - prefixlen = ip_masklen (mask.sin_addr); - - /* Point to point or borad cast address pointer init. */ - dest_pnt = NULL; - - ret = if_ioctl (SIOCGIFDSTADDR, (caddr_t) &ifreq); - if (ret < 0) - { - if (errno != EADDRNOTAVAIL) - zlog_warn ("SIOCGIFDSTADDR fail: %s", safe_strerror (errno)); - } - else if (!IPV4_ADDR_SAME(&addr.sin_addr, &ifreq.ifr_dstaddr.sin_addr)) - { - memcpy (&dest, &ifreq.ifr_dstaddr, sizeof (struct sockaddr_in)); - dest_pnt = &dest.sin_addr; - flags = ZEBRA_IFA_PEER; - } - if (!dest_pnt) - { - ret = if_ioctl (SIOCGIFBRDADDR, (caddr_t) &ifreq); - if (ret < 0) - { - if (errno != EADDRNOTAVAIL) - zlog_warn ("SIOCGIFBRDADDR fail: %s", safe_strerror (errno)); - } - else if (!IPV4_ADDR_SAME(&addr.sin_addr, &ifreq.ifr_broadaddr.sin_addr)) - { - memcpy (&dest, &ifreq.ifr_broadaddr, sizeof (struct sockaddr_in)); - dest_pnt = &dest.sin_addr; - } - } - - - /* Set address to the interface. */ - connected_add_ipv4 (ifp, flags, &addr.sin_addr, prefixlen, dest_pnt, NULL); - - return 0; -} -#endif /* HAVE_GETIFADDRS */ /* Fetch interface information via ioctl(). */ static void @@ -436,9 +311,6 @@ interface_info_ioctl () if_get_hwaddr (ifp); #endif /* SIOCGIFHWADDR */ if_get_flags (ifp); -#ifndef HAVE_GETIFADDRS - if_get_addr (ifp); -#endif /* ! HAVE_GETIFADDRS */ if_get_mtu (ifp); if_get_metric (ifp); } @@ -462,9 +334,7 @@ interface_list (struct zebra_ns *zns) interface's information. */ interface_info_ioctl (); -#ifdef HAVE_GETIFADDRS if_getaddrs (); -#endif /* HAVE_GETIFADDRS */ #if defined(HAVE_IPV6) && defined(HAVE_PROC_NET_IF_INET6) /* Linux provides interface's IPv6 address via diff --git a/zebra/interface.c b/zebra/interface.c index ff9c0a301..e9cbd72af 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -512,9 +512,10 @@ if_install_connected (struct interface *ifp) { for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc)) { - p = ifc->address; - zebra_interface_address_add_update (ifp, ifc); + if (CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL)) + zebra_interface_address_add_update (ifp, ifc); + p = ifc->address; if (p->family == AF_INET) connected_up_ipv4 (ifp, ifc); else if (p->family == AF_INET6) @@ -1222,32 +1223,6 @@ if_dump_vty (struct vty *vty, struct interface *ifp) #endif /* HAVE_NET_RT_IFLIST */ } -/* Wrapper hook point for zebra daemon so that ifindex can be set - * DEFUN macro not used as extract.pl HAS to ignore this - * See also interface_cmd in lib/if.c - */ -DEFUN_NOSH (zebra_interface, - zebra_interface_cmd, - "interface IFNAME", - "Select an interface to configure\n" - "Interface's name\n") -{ - int ret; - - /* Call lib interface() */ - if ((ret = interface_cmd.func (self, vty, argc, argv)) != CMD_SUCCESS) - return ret; - - VTY_DECLVAR_CONTEXT (interface, ifp); - - if (ifp->ifindex == IFINDEX_INTERNAL) - /* Is this really necessary? Shouldn't status be initialized to 0 - in that case? */ - UNSET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE); - - return ret; -} - static void interface_update_stats (void) { @@ -1268,6 +1243,7 @@ struct cmd_node interface_node = 1 }; +#if 0 /* Wrapper hook point for zebra daemon so that ifindex can be set * DEFUN macro not used as extract.pl HAS to ignore this * See also interface_cmd in lib/if.c @@ -1287,6 +1263,7 @@ DEFUN_NOSH (zebra_vrf, return ret; } +#endif struct cmd_node vrf_node = { @@ -2933,6 +2910,7 @@ zebra_if_init (void) install_node (&interface_node, if_config_write); install_node (&link_params_node, NULL); install_node (&vrf_node, vrf_config_write); + if_cmd_init (); install_element (VIEW_NODE, &show_interface_cmd); install_element (VIEW_NODE, &show_interface_vrf_all_cmd); @@ -2941,11 +2919,6 @@ zebra_if_init (void) install_element (ENABLE_NODE, &show_interface_desc_cmd); install_element (ENABLE_NODE, &show_interface_desc_vrf_all_cmd); - install_element (CONFIG_NODE, &zebra_interface_cmd); - install_element (CONFIG_NODE, &no_interface_cmd); - install_default (INTERFACE_NODE); - install_element (INTERFACE_NODE, &interface_desc_cmd); - install_element (INTERFACE_NODE, &no_interface_desc_cmd); install_element (INTERFACE_NODE, &multicast_cmd); install_element (INTERFACE_NODE, &no_multicast_cmd); install_element (INTERFACE_NODE, &linkdetect_cmd); @@ -2990,7 +2963,5 @@ zebra_if_init (void) install_element(LINK_PARAMS_NODE, &no_link_params_use_bw_cmd); install_element(LINK_PARAMS_NODE, &exit_link_params_cmd); - install_element (CONFIG_NODE, &zebra_vrf_cmd); - install_element (CONFIG_NODE, &no_vrf_cmd); - install_default (VRF_NODE); + vrf_cmd_init(); } diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 6cb9f7859..bcd92e15f 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -33,7 +33,6 @@ #include "zebra_memory.h" #include "ioctl.h" #include "log.h" -#include "str.h" #include "table.h" #include "rib.h" #include "privs.h" diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c index 2bde3f4b0..b2c99d981 100644 --- a/zebra/rt_socket.c +++ b/zebra/rt_socket.c @@ -29,7 +29,6 @@ #include "prefix.h" #include "sockunion.h" #include "log.h" -#include "str.h" #include "privs.h" #include "zebra/debug.h" diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 15e5c330e..3b19a5da0 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -24,7 +24,6 @@ #include "prefix.h" #include "table.h" #include "memory.h" -#include "str.h" #include "command.h" #include "if.h" #include "log.h" diff --git a/zebra/zebra_mpls_netlink.c b/zebra/zebra_mpls_netlink.c index 1f894b33c..045bee2b9 100644 --- a/zebra/zebra_mpls_netlink.c +++ b/zebra/zebra_mpls_netlink.c @@ -1,3 +1,24 @@ +/* MPLS forwarding table updates using netlink over GNU/Linux system. + * Copyright (C) 2016 Cumulus Networks, Inc. + * + * This file is part of Quagga. + * + * Quagga is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * Quagga is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Quagga; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + #include <zebra.h> #include "zebra/rt.h" #include "zebra/rt_netlink.h" diff --git a/zebra/zebra_mpls_null.c b/zebra/zebra_mpls_null.c index 7727c84a8..23f5e7295 100644 --- a/zebra/zebra_mpls_null.c +++ b/zebra/zebra_mpls_null.c @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2016 by Open Source Routing. + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + #include <zebra.h> #include "zebra/rt.h" #include "zebra/zebra_mpls.h" diff --git a/zebra/zebra_mpls_openbsd.c b/zebra/zebra_mpls_openbsd.c index bae1de66b..1127f568c 100644 --- a/zebra/zebra_mpls_openbsd.c +++ b/zebra/zebra_mpls_openbsd.c @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2016 by Open Source Routing. + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + #include <zebra.h> #include <netmpls/mpls.h> #include "zebra/rt.h" diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 394469950..8b36eb806 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -26,7 +26,6 @@ #include "table.h" #include "memory.h" #include "zebra_memory.h" -#include "str.h" #include "command.h" #include "log.h" #include "sockunion.h" diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index 8df9277cb..062f9d383 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -24,7 +24,6 @@ #include "prefix.h" #include "table.h" #include "memory.h" -#include "str.h" #include "command.h" #include "if.h" #include "log.h" diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c index 3186ebf69..19364b5b9 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -343,7 +343,7 @@ get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len, */ if (*objid_len > (unsigned) v->namelen) - oid2in_addr (objid + v->namelen, MIN(4, *objid_len - v->namelen), &dest); + oid2in_addr (objid + v->namelen, MIN(4U, *objid_len - v->namelen), &dest); if (*objid_len > (unsigned) v->namelen + 4) proto = objid[v->namelen + 4]; @@ -352,7 +352,7 @@ get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len, policy = objid[v->namelen + 5]; if (*objid_len > (unsigned) v->namelen + 6) - oid2in_addr (objid + v->namelen + 6, MIN(4, *objid_len - v->namelen - 6), + oid2in_addr (objid + v->namelen + 6, MIN(4U, *objid_len - v->namelen - 6), &nexthop); /* Apply GETNEXT on not exact search */ |