diff options
| -rw-r--r-- | bgpd/bgp_attr_evpn.c | 2 | ||||
| -rw-r--r-- | bgpd/bgp_evpn.c | 14 | ||||
| -rw-r--r-- | bgpd/bgp_evpn_private.h | 2 | ||||
| -rw-r--r-- | bgpd/bgp_rd.c | 2 | ||||
| -rw-r--r-- | bgpd/bgp_route.c | 2 | ||||
| -rw-r--r-- | bgpd/bgp_zebra.c | 2 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi.c | 4 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi_import.c | 4 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi_monitor.c | 4 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi_rib.c | 2 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi_vty.c | 4 | ||||
| -rw-r--r-- | isisd/isis_bpf.c | 10 | ||||
| -rw-r--r-- | isisd/isis_circuit.c | 4 | ||||
| -rw-r--r-- | isisd/isis_circuit.h | 1 | ||||
| -rw-r--r-- | isisd/isis_constants.h | 4 | ||||
| -rw-r--r-- | ldpd/address.c | 6 | ||||
| -rw-r--r-- | ldpd/ldp_zebra.c | 2 | ||||
| -rw-r--r-- | ldpd/ldpd.h | 4 | ||||
| -rw-r--r-- | lib/command.h | 1 | ||||
| -rw-r--r-- | lib/command_graph.c | 4 | ||||
| -rw-r--r-- | lib/prefix.c | 2 | ||||
| -rw-r--r-- | lib/prefix.h | 30 | ||||
| -rw-r--r-- | lib/vty.h | 5 | ||||
| -rw-r--r-- | ospfd/ospf_dump.c | 16 | ||||
| -rw-r--r-- | ospfd/ospf_opaque.c | 4 | ||||
| -rw-r--r-- | ospfd/ospf_te.c | 6 | ||||
| -rw-r--r-- | ospfd/ospf_vty.c | 270 | ||||
| -rw-r--r-- | pimd/pim_iface.c | 146 | ||||
| -rw-r--r-- | pimd/pim_join.c | 10 | ||||
| -rw-r--r-- | vtysh/vtysh.c | 12 | ||||
| -rw-r--r-- | zebra/rt_netlink.c | 8 | ||||
| -rw-r--r-- | zebra/zebra_vxlan.c | 37 |
32 files changed, 335 insertions, 289 deletions
diff --git a/bgpd/bgp_attr_evpn.c b/bgpd/bgp_attr_evpn.c index cd6b87b299..2f0b566ccf 100644 --- a/bgpd/bgp_attr_evpn.c +++ b/bgpd/bgp_attr_evpn.c @@ -42,7 +42,7 @@ void bgp_add_routermac_ecom(struct attr *attr, struct ethaddr *routermac) memset(&routermac_ecom, 0, sizeof(struct ecommunity_val)); routermac_ecom.val[0] = ECOMMUNITY_ENCODE_EVPN; routermac_ecom.val[1] = ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC; - memcpy(&routermac_ecom.val[2], routermac->octet, ETHER_ADDR_LEN); + memcpy(&routermac_ecom.val[2], routermac->octet, ETH_ALEN); if (!attr->ecommunity) attr->ecommunity = ecommunity_new(); ecommunity_add_val(attr->ecommunity, &routermac_ecom); diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index f0081e6d02..fe311832a2 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -351,7 +351,7 @@ static int bgp_zebra_send_remote_macip(struct bgp *bgp, struct bgpevpn *vpn, s, add ? ZEBRA_REMOTE_MACIP_ADD : ZEBRA_REMOTE_MACIP_DEL, bgp->vrf_id); stream_putl(s, vpn->vni); - stream_put(s, &p->prefix.mac.octet, ETHER_ADDR_LEN); /* Mac Addr */ + stream_put(s, &p->prefix.mac.octet, ETH_ALEN); /* Mac Addr */ /* IP address length and IP address, if any. */ if (IS_EVPN_PREFIX_IPADDR_NONE(p)) stream_putl(s, 0); @@ -1812,9 +1812,9 @@ static int process_type2_route(struct peer *peer, afi_t afi, safi_t safi, macaddr_len = *pfx++; /* Get the MAC Addr */ - if (macaddr_len == (ETHER_ADDR_LEN * 8)) { - memcpy(&p.prefix.mac.octet, pfx, ETHER_ADDR_LEN); - pfx += ETHER_ADDR_LEN; + if (macaddr_len == (ETH_ALEN * 8)) { + memcpy(&p.prefix.mac.octet, pfx, ETH_ALEN); + pfx += ETH_ALEN; } else { zlog_err( "%u:%s - Rx EVPN Type-2 NLRI with unsupported MAC address length %d", @@ -2186,7 +2186,7 @@ char *bgp_evpn_route2str(struct prefix_evpn *p, char *buf, int len) } else if (p->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) { if (IS_EVPN_PREFIX_IPADDR_NONE(p)) snprintf(buf, len, "[%d]:[0]:[0]:[%d]:[%s]", - p->prefix.route_type, 8 * ETHER_ADDR_LEN, + p->prefix.route_type, 8 * ETH_ALEN, prefix_mac2str(&p->prefix.mac, buf1, sizeof(buf1))); else { @@ -2195,7 +2195,7 @@ char *bgp_evpn_route2str(struct prefix_evpn *p, char *buf, int len) family = IS_EVPN_PREFIX_IPADDR_V4(p) ? AF_INET : AF_INET6; snprintf(buf, len, "[%d]:[0]:[0]:[%d]:[%s]:[%d]:[%s]", - p->prefix.route_type, 8 * ETHER_ADDR_LEN, + p->prefix.route_type, 8 * ETH_ALEN, prefix_mac2str(&p->prefix.mac, buf1, sizeof(buf1)), family == AF_INET ? IPV4_MAX_BITLEN @@ -2237,7 +2237,7 @@ void bgp_evpn_encode_prefix(struct stream *s, struct prefix *p, stream_put(s, prd->val, 8); /* RD */ stream_put(s, 0, 10); /* ESI */ stream_putl(s, 0); /* Ethernet Tag ID */ - stream_putc(s, 8 * ETHER_ADDR_LEN); /* Mac Addr Len - bits */ + stream_putc(s, 8 * ETH_ALEN); /* Mac Addr Len - bits */ stream_put(s, evp->prefix.mac.octet, 6); /* Mac Addr */ stream_putc(s, 8 * ipa_len); /* IP address Length */ if (ipa_len) diff --git a/bgpd/bgp_evpn_private.h b/bgpd/bgp_evpn_private.h index 816a7df98c..095dfa1b15 100644 --- a/bgpd/bgp_evpn_private.h +++ b/bgpd/bgp_evpn_private.h @@ -174,7 +174,7 @@ static inline void build_evpn_type2_prefix(struct prefix_evpn *p, p->family = AF_ETHERNET; p->prefixlen = EVPN_TYPE_2_ROUTE_PREFIXLEN; p->prefix.route_type = BGP_EVPN_MAC_IP_ROUTE; - memcpy(&p->prefix.mac.octet, mac->octet, ETHER_ADDR_LEN); + memcpy(&p->prefix.mac.octet, mac->octet, ETH_ALEN); p->prefix.ip.ipa_type = IPADDR_NONE; if (ip) memcpy(&p->prefix.ip, ip, sizeof(*ip)); diff --git a/bgpd/bgp_rd.c b/bgpd/bgp_rd.c index fd01693942..a15828bd36 100644 --- a/bgpd/bgp_rd.c +++ b/bgpd/bgp_rd.c @@ -98,7 +98,7 @@ void decode_rd_vnc_eth(u_char *pnt, struct rd_vnc_eth *rd_vnc_eth) { rd_vnc_eth->type = RD_TYPE_VNC_ETH; rd_vnc_eth->local_nve_id = pnt[1]; - memcpy(rd_vnc_eth->macaddr.octet, pnt + 2, ETHER_ADDR_LEN); + memcpy(rd_vnc_eth->macaddr.octet, pnt + 2, ETH_ALEN); } #endif diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 1fb42f6182..e4e421510f 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -4775,7 +4775,7 @@ int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty, } if (routermac) { bgp_static->router_mac = - XCALLOC(MTYPE_ATTR, ETHER_ADDR_LEN + 1); + XCALLOC(MTYPE_ATTR, ETH_ALEN + 1); prefix_str2mac(routermac, bgp_static->router_mac); } diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 4870e54aec..5071be909e 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -2125,7 +2125,7 @@ static int bgp_zebra_process_local_macip(int command, struct zclient *zclient, memset(&ip, 0, sizeof(ip)); s = zclient->ibuf; vni = stream_getl(s); - stream_get(&mac.octet, s, ETHER_ADDR_LEN); + stream_get(&mac.octet, s, ETH_ALEN); ipa_len = stream_getl(s); if (ipa_len != 0 && ipa_len != IPV4_MAX_BYTELEN && ipa_len != IPV6_MAX_BYTELEN) { diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index ab71eda126..477716cafb 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -1568,7 +1568,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target, if (l2o) { if (!memcmp(l2o->macaddr.octet, rfapi_ethaddr0.octet, - ETHER_ADDR_LEN)) { + ETH_ALEN)) { eth_is_0 = 1; } /* per t/c Paul/Lou 151022 */ @@ -3416,7 +3416,7 @@ DEFUN (debug_rfapi_query_vn_un_l2o, /* construct option chain */ memset(valbuf, 0, sizeof(valbuf)); - memcpy(valbuf, &l2o_buf.macaddr.octet, ETHER_ADDR_LEN); + memcpy(valbuf, &l2o_buf.macaddr.octet, ETH_ALEN); valbuf[11] = (l2o_buf.logical_net_id >> 16) & 0xff; valbuf[12] = (l2o_buf.logical_net_id >> 8) & 0xff; valbuf[13] = l2o_buf.logical_net_id & 0xff; diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 61739d38ab..7e0ed9150b 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -308,7 +308,7 @@ int rfapiGetL2o(struct attr *attr, struct rfapi_l2address_option *l2o) if (pEncap->value[1] == 14) { memcpy(l2o->macaddr.octet, pEncap->value + 2, - ETHER_ADDR_LEN); + ETH_ALEN); l2o->label = ((pEncap->value[10] >> 4) @@ -1327,7 +1327,7 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, vo->type = RFAPI_VN_OPTION_TYPE_L2ADDR; memcpy(&vo->v.l2addr.macaddr, &rn->p.u.prefix_eth.octet, - ETHER_ADDR_LEN); + ETH_ALEN); /* only low 3 bytes of this are significant */ if (bi->attr) { (void)rfapiEcommunityGetLNI( diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c index 9c0d9da6ff..6a7595443a 100644 --- a/bgpd/rfapi/rfapi_monitor.c +++ b/bgpd/rfapi/rfapi_monitor.c @@ -805,7 +805,7 @@ void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, struct prefix *p) (void **)&mon_eth, &cursor)) { if (!memcmp(mon_eth->macaddr.octet, - p->u.prefix_eth.octet, ETHER_ADDR_LEN)) { + p->u.prefix_eth.octet, ETH_ALEN)) { rfapiMonitorEthTimerRestart(mon_eth); } @@ -1117,7 +1117,7 @@ static int mon_eth_cmp(void *a, void *b) /* * compare ethernet addresses */ - for (i = 0; i < ETHER_ADDR_LEN; ++i) { + for (i = 0; i < ETH_ALEN; ++i) { if (m1->macaddr.octet[i] != m2->macaddr.octet[i]) return (m1->macaddr.octet[i] - m2->macaddr.octet[i]); } diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index 791eb4c916..748c0c476b 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -687,7 +687,7 @@ static void rfapiRibBi2Ri(struct bgp_info *bi, struct rfapi_info *ri, /* copy from RD already stored in bi, so we don't need it_node */ memcpy(&vo->v.l2addr.macaddr, bi->extra->vnc.import.rd.val + 2, - ETHER_ADDR_LEN); + ETH_ALEN); if (bi->attr) { (void)rfapiEcommunityGetLNI( diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 98c3decbd8..e7314d2983 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -3092,7 +3092,7 @@ static int rfapiDeleteLocalPrefixesByRFD(struct rfapi_local_reg_delete_arg *cda, if (memcmp(cda->l2o.o.macaddr.octet, adb->u.s.prefix_eth.u .prefix_eth.octet, - ETHER_ADDR_LEN)) { + ETH_ALEN)) { #if DEBUG_L2_EXTRA vnc_zlog_debug_verbose( "%s: adb=%p, macaddr doesn't match, skipping", @@ -3211,7 +3211,7 @@ static int rfapiDeleteLocalPrefixesByRFD(struct rfapi_local_reg_delete_arg *cda, adb->u.s.prefix_eth.u .prefix_eth .octet, - ETHER_ADDR_LEN)) { + ETH_ALEN)) { continue; } diff --git a/isisd/isis_bpf.c b/isisd/isis_bpf.c index 69c2f941f0..98f612f827 100644 --- a/isisd/isis_bpf.c +++ b/isisd/isis_bpf.c @@ -250,8 +250,8 @@ int isis_recv_pdu_bcast(struct isis_circuit *circuit, u_char *ssnpa) bpf_hdr->bh_caplen - LLC_LEN - ETHER_HDR_LEN); stream_set_getp(circuit->rcv_stream, 0); - memcpy(ssnpa, readbuff + bpf_hdr->bh_hdrlen + ETHER_ADDR_LEN, - ETHER_ADDR_LEN); + memcpy(ssnpa, readbuff + bpf_hdr->bh_hdrlen + ETH_ALEN, + ETH_ALEN); if (ioctl(circuit->fd, BIOCFLUSH, &one) < 0) zlog_warn("Flushing failed: %s", safe_strerror(errno)); @@ -281,10 +281,10 @@ int isis_send_pdu_bcast(struct isis_circuit *circuit, int level) */ eth = (struct ether_header *)sock_buff; if (level == 1) - memcpy(eth->ether_dhost, ALL_L1_ISS, ETHER_ADDR_LEN); + memcpy(eth->ether_dhost, ALL_L1_ISS, ETH_ALEN); else - memcpy(eth->ether_dhost, ALL_L2_ISS, ETHER_ADDR_LEN); - memcpy(eth->ether_shost, circuit->u.bc.snpa, ETHER_ADDR_LEN); + memcpy(eth->ether_dhost, ALL_L2_ISS, ETH_ALEN); + memcpy(eth->ether_shost, circuit->u.bc.snpa, ETH_ALEN); size_t frame_size = stream_get_endp(circuit->snd_stream) + LLC_LEN; eth->ether_type = htons(isis_ethertype(frame_size)); diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index c321677dee..9622dcdbc4 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -26,10 +26,6 @@ #include <netinet/if_ether.h> #endif -#ifndef ETHER_ADDR_LEN -#define ETHER_ADDR_LEN ETHERADDRL -#endif - #include "log.h" #include "memory.h" #include "vrf.h" diff --git a/isisd/isis_circuit.h b/isisd/isis_circuit.h index 5e523cd68b..ad53be4683 100644 --- a/isisd/isis_circuit.h +++ b/isisd/isis_circuit.h @@ -26,6 +26,7 @@ #include "vty.h" #include "if.h" #include "qobj.h" +#include "prefix.h" #include "isis_constants.h" #include "isis_common.h" diff --git a/isisd/isis_constants.h b/isisd/isis_constants.h index 4b5ff888ba..f3a5a24dde 100644 --- a/isisd/isis_constants.h +++ b/isisd/isis_constants.h @@ -167,10 +167,6 @@ ((if_is_broadcast((C)->interface)) ? (C->interface->mtu - LLC_LEN) \ : (C->interface->mtu)) -#ifndef ETH_ALEN -#define ETH_ALEN 6 -#endif - #define MAX_LLC_LEN 0x5ff #define ETHERTYPE_EXT_LLC 0x8870 diff --git a/ldpd/address.c b/ldpd/address.c index 584240de84..18ab037760 100644 --- a/ldpd/address.c +++ b/ldpd/address.c @@ -160,7 +160,7 @@ send_mac_withdrawal(struct nbr *nbr, struct map *fec, uint8_t *mac) size = LDP_HDR_SIZE + LDP_MSG_SIZE + ADDR_LIST_SIZE + len_fec_tlv(fec) + TLV_HDR_SIZE; if (mac) - size += ETHER_ADDR_LEN; + size += ETH_ALEN; if ((buf = ibuf_open(size)) == NULL) fatal(__func__); @@ -372,10 +372,10 @@ gen_mac_list_tlv(struct ibuf *buf, uint8_t *mac) memset(&tlv, 0, sizeof(tlv)); tlv.type = htons(TLV_TYPE_MAC_LIST); if (mac) - tlv.length = htons(ETHER_ADDR_LEN); + tlv.length = htons(ETH_ALEN); err = ibuf_add(buf, &tlv, sizeof(tlv)); if (mac) - err |= ibuf_add(buf, mac, ETHER_ADDR_LEN); + err |= ibuf_add(buf, mac, ETH_ALEN); return (err); } diff --git a/ldpd/ldp_zebra.c b/ldpd/ldp_zebra.c index 79fff01c4c..efc6bd5279 100644 --- a/ldpd/ldp_zebra.c +++ b/ldpd/ldp_zebra.c @@ -64,7 +64,7 @@ ifp2kif(struct interface *ifp, struct kif *kif) kif->ifindex = ifp->ifindex; kif->operative = if_is_operative(ifp); if (ifp->ll_type == ZEBRA_LLT_ETHER) - memcpy(kif->mac, ifp->hw_addr, ETHER_ADDR_LEN); + memcpy(kif->mac, ifp->hw_addr, ETH_ALEN); } static void diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index 352a7b0d7e..00d2627f11 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -389,7 +389,7 @@ struct l2vpn_if { char ifname[IF_NAMESIZE]; unsigned int ifindex; int operative; - uint8_t mac[ETHER_ADDR_LEN]; + uint8_t mac[ETH_ALEN]; QOBJ_FIELDS }; RB_HEAD(l2vpn_if_head, l2vpn_if); @@ -566,7 +566,7 @@ struct kif { unsigned short ifindex; int flags; int operative; - uint8_t mac[ETHER_ADDR_LEN]; + uint8_t mac[ETH_ALEN]; int mtu; }; diff --git a/lib/command.h b/lib/command.h index 533b4b3289..5184b53a9f 100644 --- a/lib/command.h +++ b/lib/command.h @@ -181,6 +181,7 @@ struct cmd_node { #define CMD_ERR_NO_FILE 11 #define CMD_SUSPEND 12 #define CMD_WARNING_CONFIG_FAILED 13 +#define CMD_NOT_MY_INSTANCE 14 /* Argc max counts. */ #define CMD_ARGC_MAX 25 diff --git a/lib/command_graph.c b/lib/command_graph.c index 3efa4d5cfc..dc7233c1fe 100644 --- a/lib/command_graph.c +++ b/lib/command_graph.c @@ -385,7 +385,6 @@ static void cmd_node_names(struct graph_node *gn, struct graph_node *join, break; case START_TKN: - case END_TKN: case JOIN_TKN: /* "<foo|bar> WORD" -> word is not "bar" or "foo" */ prevname = NULL; @@ -405,6 +404,9 @@ static void cmd_node_names(struct graph_node *gn, struct graph_node *join, cmd_token_varname_set(tailtok, jointok->varname); } break; + + case END_TKN: + return; } for (i = 0; i < vector_active(gn->to); i++) { diff --git a/lib/prefix.c b/lib/prefix.c index 47e16dbf8b..33b6ff1987 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -1062,7 +1062,7 @@ int prefix_blen(const struct prefix *p) return IPV6_MAX_BYTELEN; break; case AF_ETHERNET: - return ETHER_ADDR_LEN; + return ETH_ALEN; } return 0; } diff --git a/lib/prefix.h b/lib/prefix.h index 4f1f0b22d7..5f2b57ccce 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -34,21 +34,39 @@ #include "sockunion.h" #include "ipaddr.h" -#ifndef ETHER_ADDR_LEN -#ifdef ETHERADDRL -#define ETHER_ADDR_LEN ETHERADDRL +#ifndef ETH_ALEN +#define ETH_ALEN 6 +#endif + +/* for compatibility */ +#if defined(__ICC) +#define CPP_WARN_STR(X) #X +#define CPP_WARN(text) _Pragma(CPP_WARN_STR(message __FILE__ ": " text)) + +#elif (defined(__GNUC__) \ + && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) \ + || (defined(__clang__) \ + && (__clang_major__ >= 4 \ + || (__clang_major__ == 3 && __clang_minor__ >= 5))) +#define CPP_WARN_STR(X) #X +#define CPP_WARN(text) _Pragma(CPP_WARN_STR(GCC warning text)) + #else -#define ETHER_ADDR_LEN 6 +#define CPP_WARN(text) #endif + +#ifdef ETHER_ADDR_LEN +#undef ETHER_ADDR_LEN #endif +#define ETHER_ADDR_LEN 6 CPP_WARN("ETHER_ADDR_LEN is being replaced by ETH_ALEN.\\n") -#define ETHER_ADDR_STRLEN (3*ETHER_ADDR_LEN) +#define ETHER_ADDR_STRLEN (3*ETH_ALEN) /* * there isn't a portable ethernet address type. We define our * own to simplify internal handling */ struct ethaddr { - u_char octet[ETHER_ADDR_LEN]; + u_char octet[ETH_ALEN]; } __attribute__((packed)); @@ -166,6 +166,11 @@ static inline void vty_push_context(struct vty *vty, int node, uint64_t id) #define VTY_DECLVAR_CONTEXT_SUB(structname, ptr) \ struct structname *ptr = VTY_GET_CONTEXT_SUB(structname); \ VTY_CHECK_CONTEXT(ptr); +#define VTY_DECLVAR_INSTANCE_CONTEXT(structname, ptr) \ + if (vty->qobj_index == 0) \ + return CMD_NOT_MY_INSTANCE; \ + struct structname *ptr = VTY_GET_CONTEXT(structname); \ + VTY_CHECK_CONTEXT(ptr); struct vty_arg { const char *name; diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index c0670012b8..d3d1ffed5e 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -626,7 +626,7 @@ DEFUN (debug_ospf_packet, if (inst) // user passed instance ID { if (!ospf_lookup_instance(strtoul(argv[2]->arg, NULL, 10))) - return CMD_SUCCESS; + return CMD_NOT_MY_INSTANCE; } int type = 0; @@ -702,7 +702,7 @@ DEFUN (no_debug_ospf_packet, if (inst) // user passed instance ID { if (!ospf_lookup_instance(strtoul(argv[3]->arg, NULL, 10))) - return CMD_SUCCESS; + return CMD_NOT_MY_INSTANCE; } int type = 0; @@ -773,7 +773,7 @@ DEFUN (debug_ospf_ism, if (inst) // user passed instance ID { if (!ospf_lookup_instance(strtoul(argv[2]->arg, NULL, 10))) - return CMD_SUCCESS; + return CMD_NOT_MY_INSTANCE; } if (vty->node == CONFIG_NODE) { @@ -824,7 +824,7 @@ DEFUN (no_debug_ospf_ism, if (inst) // user passed instance ID { if (!ospf_lookup_instance(strtoul(argv[3]->arg, NULL, 10))) - return CMD_SUCCESS; + return CMD_NOT_MY_INSTANCE; } if (vty->node == CONFIG_NODE) { @@ -991,7 +991,7 @@ DEFUN (no_debug_ospf_instance_nsm, instance = strtoul(argv[idx_number]->arg, NULL, 10); if (!ospf_lookup_instance(instance)) - return CMD_SUCCESS; + return CMD_NOT_MY_INSTANCE; return no_debug_ospf_nsm_common(vty, 5, argc, argv); } @@ -1065,7 +1065,7 @@ DEFUN (debug_ospf_instance_lsa, instance = strtoul(argv[idx_number]->arg, NULL, 10); if (!ospf_lookup_instance(instance)) - return CMD_SUCCESS; + return CMD_NOT_MY_INSTANCE; return debug_ospf_lsa_common(vty, 4, argc, argv); } @@ -1141,7 +1141,7 @@ DEFUN (no_debug_ospf_instance_lsa, instance = strtoul(argv[idx_number]->arg, NULL, 10); if (!ospf_lookup_instance(instance)) - return CMD_SUCCESS; + return CMD_NOT_MY_INSTANCE; return no_debug_ospf_lsa_common(vty, 5, argc, argv); } @@ -1203,7 +1203,7 @@ DEFUN (debug_ospf_instance_zebra, instance = strtoul(argv[idx_number]->arg, NULL, 10); if (!ospf_lookup_instance(instance)) - return CMD_SUCCESS; + return CMD_NOT_MY_INSTANCE; return debug_ospf_zebra_common(vty, 4, argc, argv); } diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index a2c40923b1..db523bd2a4 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -750,7 +750,7 @@ DEFUN (capability_opaque, "Enable specific OSPF feature\n" "Opaque LSA\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); /* Turn on the "master switch" of opaque-lsa capability. */ if (!CHECK_FLAG(ospf->config, OSPF_OPAQUE_CAPABLE)) { @@ -779,7 +779,7 @@ DEFUN (no_capability_opaque, "Enable specific OSPF feature\n" "Opaque LSA\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); /* Turn off the "master switch" of opaque-lsa capability. */ if (CHECK_FLAG(ospf->config, OSPF_OPAQUE_CAPABLE)) { diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index 482d9d48c5..1c1c76c1af 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -2179,7 +2179,7 @@ DEFUN (ospf_mpls_te_on, MPLS_TE_STR "Enable the MPLS-TE functionality\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); struct listnode *node; struct mpls_te_link *lp; @@ -2215,7 +2215,7 @@ DEFUN (no_ospf_mpls_te, MPLS_TE_STR "Disable the MPLS-TE functionality\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); struct listnode *node, *nnode; struct mpls_te_link *lp; @@ -2242,7 +2242,7 @@ DEFUN (ospf_mpls_te_router_addr, "Stable IP address of the advertising router\n" "MPLS-TE router address in IPv4 address format\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4 = 2; struct te_tlv_router_addr *ra = &OspfMplsTE.router_addr; struct in_addr value; diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index a8bfb669af..78f965abbf 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -135,6 +135,7 @@ DEFUN_NOSH (router_ospf, { struct ospf *ospf; u_short instance = 0; + int ret = CMD_SUCCESS; ospf = ospf_lookup(); if (!ospf) { @@ -147,9 +148,10 @@ DEFUN_NOSH (router_ospf, /* The following logic to set the vty qobj index is in place to be able to ignore the commands which dont belong to this instance. */ - if (ospf->instance != instance) + if (ospf->instance != instance) { VTY_PUSH_CONTEXT_NULL(OSPF_NODE); - else { + ret = CMD_NOT_MY_INSTANCE; + } else { if (IS_DEBUG_OSPF_EVENT) zlog_debug("Config command 'router ospf %d' received", instance); @@ -158,7 +160,7 @@ DEFUN_NOSH (router_ospf, ospf_router_id_update(ospf); } - return CMD_SUCCESS; + return ret; } DEFUN (no_router_ospf, @@ -175,8 +177,9 @@ DEFUN (no_router_ospf, if (argc > 3) instance = strtoul(argv[3]->arg, NULL, 10); - if ((ospf = ospf_lookup_instance(instance)) == NULL) - return CMD_SUCCESS; + ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; ospf_finish(ospf); @@ -191,7 +194,7 @@ DEFUN (ospf_router_id, "router-id for the OSPF process\n" "OSPF router-id in IP address format\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4 = 2; struct listnode *node; struct ospf_area *area; @@ -225,7 +228,7 @@ DEFUN_HIDDEN (ospf_router_id_old, "router-id for the OSPF process\n" "OSPF router-id in IP address format\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4 = 1; struct listnode *node; struct ospf_area *area; @@ -261,7 +264,7 @@ DEFUN (no_ospf_router_id, "router-id for the OSPF process\n" "OSPF router-id in IP address format\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); struct listnode *node; struct ospf_area *area; @@ -350,7 +353,7 @@ DEFUN (ospf_passive_interface, "IPv4 address\n" "Suppress routing updates on interfaces by default\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4 = 2; struct interface *ifp; struct in_addr addr = {.s_addr = INADDR_ANY}; @@ -417,7 +420,7 @@ DEFUN (no_ospf_passive_interface, "IPv4 address\n" "Allow routing updates on interfaces by default\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4 = 3; struct interface *ifp; struct in_addr addr = {.s_addr = INADDR_ANY}; @@ -478,7 +481,7 @@ DEFUN (ospf_network_area, "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_prefixlen = 1; int idx_ipv4_number = 3; struct prefix_ipv4 p; @@ -520,7 +523,7 @@ DEFUN (no_ospf_network_area, "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_prefixlen = 2; int idx_ipv4_number = 4; struct prefix_ipv4 p; @@ -559,7 +562,7 @@ DEFUN (ospf_area_range, "User specified metric for this range\n" "Advertised metric for this range\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 1; int idx_ipv4_prefixlen = 3; int idx_cost = 6; @@ -591,7 +594,7 @@ DEFUN (ospf_area_range_cost, "User specified metric for this range\n" "Advertised metric for this range\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 1; int idx_ipv4_prefixlen = 3; int idx_cost = 5; @@ -623,7 +626,7 @@ DEFUN (ospf_area_range_not_advertise, "Area range prefix\n" "DoNotAdvertise this range\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 1; int idx_ipv4_prefixlen = 3; struct prefix_ipv4 p; @@ -656,7 +659,7 @@ DEFUN (no_ospf_area_range, "Advertised metric for this range\n" "DoNotAdvertise this range\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 2; int idx_ipv4_prefixlen = 4; struct prefix_ipv4 p; @@ -682,7 +685,7 @@ DEFUN (ospf_area_range_substitute, "Announce area range as another prefix\n" "Network prefix to be announced instead of range\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 1; int idx_ipv4_prefixlen = 3; int idx_ipv4_prefixlen_2 = 5; @@ -713,7 +716,7 @@ DEFUN (no_ospf_area_range_substitute, "Announce area range as another prefix\n" "Network prefix to be announced instead of range\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 2; int idx_ipv4_prefixlen = 4; int idx_ipv4_prefixlen_2 = 6; @@ -981,7 +984,7 @@ DEFUN (ospf_area_vlink, "Use MD5 algorithm\n" \ "The OSPF password (key)") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 1; int idx_ipv4 = 3; struct ospf_vl_config_data vl_config; @@ -1105,7 +1108,7 @@ DEFUN (no_ospf_area_vlink, "Use MD5 algorithm\n" \ "The OSPF password (key)") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 2; int idx_ipv4 = 4; struct ospf_area *area; @@ -1204,7 +1207,7 @@ DEFUN (ospf_area_vlink_intervals, VLINK_HELPSTR_IPADDR VLINK_HELPSTR_TIME_PARAM) { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); struct ospf_vl_config_data vl_config; int ret = 0; @@ -1251,7 +1254,7 @@ DEFUN (no_ospf_area_vlink_intervals, VLINK_HELPSTR_IPADDR VLINK_HELPSTR_TIME_PARAM) { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); struct ospf_vl_config_data vl_config; int ret = 0; @@ -1300,7 +1303,7 @@ DEFUN (ospf_area_shortcut, "Enable shortcutting through the area\n" "Disable shortcutting through the area\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 1; int idx_enable_disable = 3; struct ospf_area *area; @@ -1344,7 +1347,7 @@ DEFUN (no_ospf_area_shortcut, "Deconfigure enabled shortcutting through the area\n" "Deconfigure disabled shortcutting through the area\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 2; struct ospf_area *area; struct in_addr area_id; @@ -1371,7 +1374,7 @@ DEFUN (ospf_area_stub, "OSPF area ID as a decimal value\n" "Configure OSPF area as stub\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 1; struct in_addr area_id; int ret, format; @@ -1402,7 +1405,7 @@ DEFUN (ospf_area_stub_no_summary, "Configure OSPF area as stub\n" "Do not inject inter-area routes into stub\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 1; struct in_addr area_id; int ret, format; @@ -1433,7 +1436,7 @@ DEFUN (no_ospf_area_stub, "OSPF area ID as a decimal value\n" "Configure OSPF area as stub\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 2; struct in_addr area_id; int format; @@ -1457,7 +1460,7 @@ DEFUN (no_ospf_area_stub_no_summary, "Configure OSPF area as stub\n" "Do not inject inter-area routes into area\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 2; struct in_addr area_id; int format; @@ -1472,7 +1475,7 @@ DEFUN (no_ospf_area_stub_no_summary, static int ospf_area_nssa_cmd_handler(struct vty *vty, int argc, struct cmd_token **argv, int nosum) { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); struct in_addr area_id; int ret, format; @@ -1577,7 +1580,7 @@ DEFUN (no_ospf_area_nssa, "Configure NSSA-ABR to always translate\n" "Do not inject inter-area routes into nssa\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 2; struct in_addr area_id; int format; @@ -1603,7 +1606,7 @@ DEFUN (ospf_area_default_cost, "Set the summary-default cost of a NSSA or stub area\n" "Stub's advertised default summary cost\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 1; int idx_number = 3; struct ospf_area *area; @@ -1649,7 +1652,7 @@ DEFUN (no_ospf_area_default_cost, "Set the summary-default cost of a NSSA or stub area\n" "Stub's advertised default summary cost\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 2; struct ospf_area *area; struct in_addr area_id; @@ -1695,7 +1698,7 @@ DEFUN (ospf_area_export_list, "Set the filter for networks announced to other areas\n" "Name of the access-list\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 1; struct ospf_area *area; struct in_addr area_id; @@ -1720,7 +1723,7 @@ DEFUN (no_ospf_area_export_list, "Unset the filter for networks announced to other areas\n" "Name of the access-list\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 2; struct ospf_area *area; struct in_addr area_id; @@ -1747,7 +1750,7 @@ DEFUN (ospf_area_import_list, "Set the filter for networks from other areas announced to the specified one\n" "Name of the access-list\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 1; struct ospf_area *area; struct in_addr area_id; @@ -1772,7 +1775,7 @@ DEFUN (no_ospf_area_import_list, "Unset the filter for networks announced to other areas\n" "Name of the access-list\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 2; struct ospf_area *area; struct in_addr area_id; @@ -1801,7 +1804,7 @@ DEFUN (ospf_area_filter_list, "Filter networks sent to this area\n" "Filter networks sent from this area\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 1; int idx_word = 4; int idx_in_out = 5; @@ -1847,7 +1850,7 @@ DEFUN (no_ospf_area_filter_list, "Filter networks sent to this area\n" "Filter networks sent from this area\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 2; int idx_word = 5; int idx_in_out = 6; @@ -1901,7 +1904,7 @@ DEFUN (ospf_area_authentication_message_digest, "Enable authentication\n" "Use message-digest authentication\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 1; struct ospf_area *area; struct in_addr area_id; @@ -1924,7 +1927,7 @@ DEFUN (ospf_area_authentication, "OSPF area ID as a decimal value\n" "Enable authentication\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 1; struct ospf_area *area; struct in_addr area_id; @@ -1948,7 +1951,7 @@ DEFUN (no_ospf_area_authentication, "OSPF area ID as a decimal value\n" "Enable authentication\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4_number = 2; struct ospf_area *area; struct in_addr area_id; @@ -1978,7 +1981,7 @@ DEFUN (ospf_abr_type, "Shortcut ABR\n" "Standard behavior (RFC2328)\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_vendor = 2; u_char abr_type = OSPF_ABR_UNKNOWN; @@ -2013,7 +2016,7 @@ DEFUN (no_ospf_abr_type, "Shortcut ABR\n" "Standard ABR\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_vendor = 3; u_char abr_type = OSPF_ABR_UNKNOWN; @@ -2042,7 +2045,7 @@ DEFUN (ospf_log_adjacency_changes, "log-adjacency-changes", "Log changes in adjacency state\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); @@ -2055,7 +2058,7 @@ DEFUN (ospf_log_adjacency_changes_detail, "Log changes in adjacency state\n" "Log all state changes\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); @@ -2068,7 +2071,7 @@ DEFUN (no_ospf_log_adjacency_changes, NO_STR "Log changes in adjacency state\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); @@ -2082,7 +2085,7 @@ DEFUN (no_ospf_log_adjacency_changes_detail, "Log changes in adjacency state\n" "Log all state changes\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); return CMD_SUCCESS; @@ -2094,7 +2097,7 @@ DEFUN (ospf_compatible_rfc1583, "OSPF compatibility list\n" "compatible with RFC 1583\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); if (!CHECK_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE)) { SET_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE); @@ -2110,7 +2113,7 @@ DEFUN (no_ospf_compatible_rfc1583, "OSPF compatibility list\n" "compatible with RFC 1583\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); if (CHECK_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE)) { UNSET_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE); @@ -2132,7 +2135,7 @@ ALIAS(no_ospf_compatible_rfc1583, no_ospf_rfc1583_flag_cmd, static int ospf_timers_spf_set(struct vty *vty, unsigned int delay, unsigned int hold, unsigned int max) { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); ospf->spf_delay = delay; ospf->spf_holdtime = hold; @@ -2150,7 +2153,7 @@ DEFUN (ospf_timers_min_ls_interval, "All LSA types\n" "Delay (msec) between sending LSAs\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_number = 4; unsigned int interval; @@ -2176,7 +2179,7 @@ DEFUN (no_ospf_timers_min_ls_interval, "All LSA types\n" "Delay (msec) between sending LSAs\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL; return CMD_SUCCESS; @@ -2191,7 +2194,7 @@ DEFUN (ospf_timers_min_ls_arrival, "OSPF minimum arrival interval delay\n" "Delay (msec) between accepted LSAs\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_number = 3; unsigned int arrival; @@ -2216,7 +2219,7 @@ DEFUN (no_ospf_timers_min_ls_arrival, "OSPF minimum arrival interval delay\n" "Delay (msec) between accepted LSAs\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; @@ -2276,7 +2279,7 @@ DEFUN (ospf_timers_lsa, "Minimum delay in receiving new version of a LSA\n" "Delay in milliseconds\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_number = 3; unsigned int minarrival; @@ -2301,7 +2304,7 @@ DEFUN (no_ospf_timers_lsa, "Minimum delay in receiving new version of a LSA\n" "Delay in milliseconds\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); unsigned int minarrival; if (argc > 4) { @@ -2327,7 +2330,7 @@ DEFUN (ospf_neighbor, "Dead Neighbor Polling interval\n" "Seconds\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4 = 1; int idx_pri = 3; int idx_poll = 5; @@ -2364,7 +2367,7 @@ DEFUN (ospf_neighbor_poll_interval, "OSPF priority of non-broadcast neighbor\n" "Priority\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4 = 1; int idx_poll = 3; int idx_pri = 5; @@ -2399,7 +2402,7 @@ DEFUN (no_ospf_neighbor, "Dead Neighbor Polling interval\n" "Seconds\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4 = 2; struct in_addr nbr_addr; @@ -2421,7 +2424,7 @@ DEFUN (no_ospf_neighbor_poll, "Neighbor Priority\n" "Priority\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ipv4 = 2; struct in_addr nbr_addr; @@ -2439,7 +2442,7 @@ DEFUN (ospf_refresh_timer, "Set refresh timer\n" "Timer value in seconds\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_number = 2; unsigned int interval; @@ -2460,7 +2463,7 @@ DEFUN (no_ospf_refresh_timer, "Unset refresh timer\n" "Timer value in seconds\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_number = 3; unsigned int interval; @@ -2485,7 +2488,7 @@ DEFUN (ospf_auto_cost_reference_bandwidth, "Use reference bandwidth method to assign OSPF cost\n" "The reference bandwidth in terms of Mbits per second\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_number = 2; u_int32_t refbw; struct listnode *node; @@ -2516,7 +2519,7 @@ DEFUN (no_ospf_auto_cost_reference_bandwidth, "Use reference bandwidth method to assign OSPF cost\n" "The reference bandwidth in terms of Mbits per second\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); struct listnode *node, *nnode; struct interface *ifp; @@ -2541,7 +2544,7 @@ DEFUN (ospf_write_multiplier, "Write multiplier\n" "Maximum number of interface serviced per write\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_number; u_int32_t write_oi_count; @@ -2572,7 +2575,7 @@ DEFUN (no_ospf_write_multiplier, "Write multiplier\n" "Maximum number of interface serviced per write\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT; return CMD_SUCCESS; @@ -3218,8 +3221,11 @@ DEFUN (show_ip_ospf_instance, u_char uj = use_json(argc, argv); instance = strtoul(argv[idx_number]->arg, NULL, 10); - if ((ospf = ospf_lookup_instance(instance)) == NULL - || !ospf->oi_running) + ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; + + if (!ospf->oi_running) return CMD_SUCCESS; return (show_ip_ospf_common(vty, ospf, uj)); @@ -3654,8 +3660,11 @@ DEFUN (show_ip_ospf_instance_interface, u_char uj = use_json(argc, argv); instance = strtoul(argv[idx_number]->arg, NULL, 10); - if ((ospf = ospf_lookup_instance(instance)) == NULL - || !ospf->oi_running) + ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; + + if (!ospf->oi_running) return CMD_SUCCESS; if (uj) @@ -3861,8 +3870,11 @@ DEFUN (show_ip_ospf_instance_neighbor, u_char uj = use_json(argc, argv); instance = strtoul(argv[idx_number]->arg, NULL, 10); - if ((ospf = ospf_lookup_instance(instance)) == NULL - || !ospf->oi_running) + ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; + + if (!ospf->oi_running) return CMD_SUCCESS; return show_ip_ospf_neighbor_common(vty, ospf, uj); @@ -3982,8 +3994,11 @@ DEFUN (show_ip_ospf_instance_neighbor_all, u_char uj = use_json(argc, argv); instance = strtoul(argv[idx_number]->arg, NULL, 10); - if ((ospf = ospf_lookup_instance(instance)) == NULL - || !ospf->oi_running) + ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; + + if (!ospf->oi_running) return CMD_SUCCESS; return show_ip_ospf_neighbor_all_common(vty, ospf, uj); @@ -4075,8 +4090,11 @@ DEFUN (show_ip_ospf_instance_neighbor_int, u_char uj = use_json(argc, argv); instance = strtoul(argv[idx_number]->arg, NULL, 10); - if ((ospf = ospf_lookup_instance(instance)) == NULL - || !ospf->oi_running) + ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; + + if (!ospf->oi_running) return CMD_SUCCESS; return show_ip_ospf_neighbor_int_common(vty, ospf, 1, argv, uj); @@ -4462,8 +4480,11 @@ DEFUN (show_ip_ospf_instance_neighbor_id, u_char uj = use_json(argc, argv); instance = strtoul(argv[idx_number]->arg, NULL, 10); - if ((ospf = ospf_lookup_instance(instance)) == NULL - || !ospf->oi_running) + ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; + + if (!ospf->oi_running) return CMD_SUCCESS; return show_ip_ospf_neighbor_id_common(vty, ospf, 1, argv, uj); @@ -4551,8 +4572,11 @@ DEFUN (show_ip_ospf_instance_neighbor_detail, u_char uj = use_json(argc, argv); instance = strtoul(argv[idx_number]->arg, NULL, 10); - if ((ospf = ospf_lookup_instance(instance)) == NULL - || !ospf->oi_running) + ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; + + if (!ospf->oi_running) return CMD_SUCCESS; return show_ip_ospf_neighbor_detail_common(vty, ospf, uj); @@ -4652,8 +4676,11 @@ DEFUN (show_ip_ospf_instance_neighbor_detail_all, u_char uj = use_json(argc, argv); instance = strtoul(argv[idx_number]->arg, NULL, 10); - if ((ospf = ospf_lookup_instance(instance)) == NULL - || !ospf->oi_running) + ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; + + if (!ospf->oi_running) return CMD_SUCCESS; return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj); @@ -4757,8 +4784,11 @@ DEFUN (show_ip_ospf_instance_neighbor_int_detail, u_char uj = use_json(argc, argv); instance = strtoul(argv[idx_number]->arg, NULL, 10); - if ((ospf = ospf_lookup_instance(instance)) == NULL - || !ospf->oi_running) + ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; + + if (!ospf->oi_running) return CMD_SUCCESS; return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 1, argv, uj); @@ -5446,6 +5476,8 @@ DEFUN (show_ip_ospf_instance_database, if (argv_find(argv, argc, "(1-65535)", &idx)) { instance = strtoul(argv[idx]->arg, NULL, 10); ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; } else { ospf = ospf_lookup(); } @@ -5474,8 +5506,11 @@ DEFUN (show_ip_ospf_instance_database_max, instance = strtoul(argv[idx_number]->arg, NULL, 10); - if ((ospf = ospf_lookup_instance(instance)) == NULL - || !ospf->oi_running) + ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; + + if (!ospf->oi_running) return CMD_SUCCESS; return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv)); @@ -5553,6 +5588,8 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router, if (argv_find(argv, argc, "(1-65535)", &idx)) { instance = strtoul(argv[idx]->arg, NULL, 10); ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; } else ospf = ospf_lookup(); @@ -6922,7 +6959,7 @@ DEFUN (ip_ospf_area, ospf = ospf_lookup(); ospf->if_ospf_cli_count--; } - return CMD_SUCCESS; + return CMD_NOT_MY_INSTANCE; } ret = str2area_id(areaid, &area_id, &format); @@ -6995,8 +7032,9 @@ DEFUN (no_ip_ospf_area, if (argv_find(argv, argc, "(1-65535)", &idx)) instance = strtol(argv[idx]->arg, NULL, 10); - if ((ospf = ospf_lookup_instance(instance)) == NULL) - return CMD_SUCCESS; + ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; argv_find(argv, argc, "area", &idx); @@ -7038,7 +7076,7 @@ DEFUN (ospf_redistribute_source, "Route map reference\n" "Pointer to route-map entries\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_protocol = 1; int source; int type = -1; @@ -7088,7 +7126,7 @@ DEFUN (no_ospf_redistribute_source, "Route map reference\n" "Pointer to route-map entries\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_protocol = 2; int source; struct ospf_redist *red; @@ -7119,7 +7157,7 @@ DEFUN (ospf_redistribute_instance_source, "Route map reference\n" "Pointer to route-map entries\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ospf_table = 1; int idx_number = 2; int idx = 3; @@ -7187,7 +7225,7 @@ DEFUN (no_ospf_redistribute_instance_source, "Route map reference\n" "Pointer to route-map entries\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_ospf_table = 2; int idx_number = 3; u_int instance; @@ -7228,7 +7266,7 @@ DEFUN (ospf_distribute_list_out, OUT_STR FRR_REDIST_HELP_STR_OSPFD) { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_word = 1; int source; @@ -7251,7 +7289,7 @@ DEFUN (no_ospf_distribute_list_out, OUT_STR FRR_REDIST_HELP_STR_OSPFD) { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_word = 2; int source; @@ -7278,7 +7316,7 @@ DEFUN (ospf_default_information_originate, "Route map reference\n" "Pointer to route-map entries\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int default_originate = DEFAULT_ORIGINATE_ZEBRA; int type = -1; int metric = -1; @@ -7324,7 +7362,7 @@ DEFUN (no_ospf_default_information_originate, "Route map reference\n" "Pointer to route-map entries\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); struct prefix_ipv4 p; struct ospf_external *ext; struct ospf_redist *red; @@ -7355,7 +7393,7 @@ DEFUN (ospf_default_metric, "Set metric of redistributed routes\n" "Default metric\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_number = 1; int metric = -1; @@ -7374,7 +7412,7 @@ DEFUN (no_ospf_default_metric, "Set metric of redistributed routes\n" "Default metric\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); ospf->default_metric = -1; @@ -7388,7 +7426,7 @@ DEFUN (ospf_distance, "Administrative distance\n" "OSPF Administrative distance\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_number = 1; ospf->distance_all = atoi(argv[idx_number]->arg); @@ -7403,7 +7441,7 @@ DEFUN (no_ospf_distance, "Administrative distance\n" "OSPF Administrative distance\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); ospf->distance_all = 0; @@ -7423,7 +7461,7 @@ DEFUN (no_ospf_distance_ospf, "External routes\n" "Distance for external routes\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx = 0; if (!ospf) @@ -7451,7 +7489,7 @@ DEFUN (ospf_distance_ospf, "External routes\n" "Distance for external routes\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx = 0; if (argv_find(argv, argc, "intra-area", &idx)) @@ -7636,7 +7674,7 @@ DEFUN (ospf_max_metric_router_lsa_admin, "Advertise own Router-LSA with infinite distance (stub router)\n" "Administratively applied, for an indefinite period\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); struct listnode *ln; struct ospf_area *area; @@ -7662,7 +7700,7 @@ DEFUN (no_ospf_max_metric_router_lsa_admin, "Advertise own Router-LSA with infinite distance (stub router)\n" "Administratively applied, for an indefinite period\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); struct listnode *ln; struct ospf_area *area; @@ -7691,7 +7729,7 @@ DEFUN (ospf_max_metric_router_lsa_startup, "Automatically advertise stub Router-LSA on startup of OSPF\n" "Time (seconds) to advertise self as stub-router\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_number = 3; unsigned int seconds; @@ -7716,7 +7754,7 @@ DEFUN (no_ospf_max_metric_router_lsa_startup, "Automatically advertise stub Router-LSA on startup of OSPF\n" "Time (seconds) to advertise self as stub-router\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); struct listnode *ln; struct ospf_area *area; @@ -7747,7 +7785,7 @@ DEFUN (ospf_max_metric_router_lsa_shutdown, "Advertise stub-router prior to full shutdown of OSPF\n" "Time (seconds) to wait till full shutdown\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); int idx_number = 3; unsigned int seconds; @@ -7772,7 +7810,7 @@ DEFUN (no_ospf_max_metric_router_lsa_shutdown, "Advertise stub-router prior to full shutdown of OSPF\n" "Time (seconds) to wait till full shutdown\n") { - VTY_DECLVAR_CONTEXT(ospf, ospf); + VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; @@ -8034,8 +8072,11 @@ DEFUN (show_ip_ospf_instance_border_routers, u_short instance = 0; instance = strtoul(argv[idx_number]->arg, NULL, 10); - if ((ospf = ospf_lookup_instance(instance)) == NULL - || !ospf->oi_running) + ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; + + if (!ospf->oi_running) return CMD_SUCCESS; return show_ip_ospf_border_routers_common(vty, ospf); @@ -8095,8 +8136,11 @@ DEFUN (show_ip_ospf_instance_route, u_short instance = 0; instance = strtoul(argv[idx_number]->arg, NULL, 10); - if ((ospf = ospf_lookup_instance(instance)) == NULL - || !ospf->oi_running) + ospf = ospf_lookup_instance(instance); + if (ospf == NULL) + return CMD_NOT_MY_INSTANCE; + + if (!ospf->oi_running) return CMD_SUCCESS; return show_ip_ospf_route_common(vty, ospf); diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 9fdbf7b3e3..1afcff7cb1 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -69,17 +69,14 @@ static void *if_list_clean(struct pim_interface *pim_ifp) { struct pim_ifchannel *ch; - if (pim_ifp->igmp_join_list) { + if (pim_ifp->igmp_join_list) list_delete(pim_ifp->igmp_join_list); - } - if (pim_ifp->igmp_socket_list) { + if (pim_ifp->igmp_socket_list) list_delete(pim_ifp->igmp_socket_list); - } - if (pim_ifp->pim_neighbor_list) { + if (pim_ifp->pim_neighbor_list) list_delete(pim_ifp->pim_neighbor_list); - } if (pim_ifp->upstream_switch_list) list_delete(pim_ifp->upstream_switch_list); @@ -96,6 +93,38 @@ static void *if_list_clean(struct pim_interface *pim_ifp) return 0; } +static void pim_sec_addr_free(struct pim_secondary_addr *sec_addr) +{ + XFREE(MTYPE_PIM_SEC_ADDR, sec_addr); +} + +static int pim_sec_addr_comp(const void *p1, const void *p2) +{ + const struct pim_secondary_addr *sec1 = p1; + const struct pim_secondary_addr *sec2 = p2; + + if (sec1->addr.family == AF_INET && sec2->addr.family == AF_INET6) + return -1; + + if (sec1->addr.family == AF_INET6 && sec2->addr.family == AF_INET) + return 1; + + if (sec1->addr.family == AF_INET) { + if (ntohl(sec1->addr.u.prefix4.s_addr) + < ntohl(sec2->addr.u.prefix4.s_addr)) + return -1; + + if (ntohl(sec1->addr.u.prefix4.s_addr) + > ntohl(sec2->addr.u.prefix4.s_addr)) + return 1; + } else { + return memcmp(&sec1->addr.u.prefix6, &sec2->addr.u.prefix6, + sizeof(struct in6_addr)); + } + + return 0; +} + struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim) { struct pim_interface *pim_ifp; @@ -146,8 +175,8 @@ struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim) /* list of struct igmp_sock */ pim_ifp->igmp_socket_list = list_new(); if (!pim_ifp->igmp_socket_list) { - zlog_err("%s %s: failure: igmp_socket_list=list_new()", - __FILE__, __PRETTY_FUNCTION__); + zlog_err("%s: failure: igmp_socket_list=list_new()", + __PRETTY_FUNCTION__); return if_list_clean(pim_ifp); } pim_ifp->igmp_socket_list->del = (void (*)(void *))igmp_sock_free; @@ -155,22 +184,31 @@ struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim) /* list of struct pim_neighbor */ pim_ifp->pim_neighbor_list = list_new(); if (!pim_ifp->pim_neighbor_list) { - zlog_err("%s %s: failure: pim_neighbor_list=list_new()", - __FILE__, __PRETTY_FUNCTION__); + zlog_err("%s: failure: pim_neighbor_list=list_new()", + __PRETTY_FUNCTION__); return if_list_clean(pim_ifp); } pim_ifp->pim_neighbor_list->del = (void (*)(void *))pim_neighbor_free; pim_ifp->upstream_switch_list = list_new(); if (!pim_ifp->upstream_switch_list) { - zlog_err("%s %s: failure: upstream_switch_list=list_new()", - __FILE__, __PRETTY_FUNCTION__); + zlog_err("%s: failure: upstream_switch_list=list_new()", + __PRETTY_FUNCTION__); return if_list_clean(pim_ifp); } pim_ifp->upstream_switch_list->del = (void (*)(void *))pim_jp_agg_group_list_free; pim_ifp->upstream_switch_list->cmp = pim_jp_agg_group_list_cmp; + pim_ifp->sec_addr_list = list_new(); + if (!pim_ifp->sec_addr_list) { + zlog_err("%s: failure: secondary addresslist", + __PRETTY_FUNCTION__); + } + pim_ifp->sec_addr_list->del = (void (*)(void *))pim_sec_addr_free; + pim_ifp->sec_addr_list->cmp = + (int (*)(void *, void *))pim_sec_addr_comp; + RB_INIT(pim_ifchannel_rb, &pim_ifp->ifchannel_rb); ifp->info = pim_ifp; @@ -314,48 +352,12 @@ static int detect_primary_address_change(struct interface *ifp, return changed; } -static int pim_sec_addr_comp(const void *p1, const void *p2) -{ - const struct pim_secondary_addr *sec1 = p1; - const struct pim_secondary_addr *sec2 = p2; - - if (sec1->addr.family == AF_INET && sec2->addr.family == AF_INET6) - return -1; - - if (sec1->addr.family == AF_INET6 && sec2->addr.family == AF_INET) - return 1; - - if (sec1->addr.family == AF_INET) { - if (ntohl(sec1->addr.u.prefix4.s_addr) - < ntohl(sec2->addr.u.prefix4.s_addr)) - return -1; - - if (ntohl(sec1->addr.u.prefix4.s_addr) - > ntohl(sec2->addr.u.prefix4.s_addr)) - return 1; - } else { - return memcmp(&sec1->addr.u.prefix6, &sec2->addr.u.prefix6, - sizeof(struct in6_addr)); - } - - return 0; -} - -static void pim_sec_addr_free(struct pim_secondary_addr *sec_addr) -{ - XFREE(MTYPE_PIM_SEC_ADDR, sec_addr); -} - static struct pim_secondary_addr * pim_sec_addr_find(struct pim_interface *pim_ifp, struct prefix *addr) { struct pim_secondary_addr *sec_addr; struct listnode *node; - if (!pim_ifp->sec_addr_list) { - return NULL; - } - for (ALL_LIST_ELEMENTS_RO(pim_ifp->sec_addr_list, node, sec_addr)) { if (prefix_cmp(&sec_addr->addr, addr)) { return sec_addr; @@ -383,22 +385,9 @@ static int pim_sec_addr_add(struct pim_interface *pim_ifp, struct prefix *addr) return changed; } - if (!pim_ifp->sec_addr_list) { - pim_ifp->sec_addr_list = list_new(); - pim_ifp->sec_addr_list->del = - (void (*)(void *))pim_sec_addr_free; - pim_ifp->sec_addr_list->cmp = - (int (*)(void *, void *))pim_sec_addr_comp; - } - sec_addr = XCALLOC(MTYPE_PIM_SEC_ADDR, sizeof(*sec_addr)); - if (!sec_addr) { - if (list_isempty(pim_ifp->sec_addr_list)) { - list_free(pim_ifp->sec_addr_list); - pim_ifp->sec_addr_list = NULL; - } + if (!sec_addr) return changed; - } changed = 1; sec_addr->addr = *addr; @@ -411,15 +400,10 @@ static int pim_sec_addr_del_all(struct pim_interface *pim_ifp) { int changed = 0; - if (!pim_ifp->sec_addr_list) { - return changed; - } if (!list_isempty(pim_ifp->sec_addr_list)) { changed = 1; /* remove all nodes and free up the list itself */ list_delete_all_node(pim_ifp->sec_addr_list); - list_free(pim_ifp->sec_addr_list); - pim_ifp->sec_addr_list = NULL; } return changed; @@ -434,11 +418,9 @@ static int pim_sec_addr_update(struct interface *ifp) struct pim_secondary_addr *sec_addr; int changed = 0; - if (pim_ifp->sec_addr_list) { - for (ALL_LIST_ELEMENTS_RO(pim_ifp->sec_addr_list, node, - sec_addr)) { - sec_addr->flags |= PIM_SEC_ADDRF_STALE; - } + for (ALL_LIST_ELEMENTS_RO(pim_ifp->sec_addr_list, node, + sec_addr)) { + sec_addr->flags |= PIM_SEC_ADDRF_STALE; } for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) { @@ -459,20 +441,12 @@ static int pim_sec_addr_update(struct interface *ifp) } } - if (pim_ifp->sec_addr_list) { - /* Drop stale entries */ - for (ALL_LIST_ELEMENTS(pim_ifp->sec_addr_list, node, nextnode, - sec_addr)) { - if (sec_addr->flags & PIM_SEC_ADDRF_STALE) { - pim_sec_addr_del(pim_ifp, sec_addr); - changed = 1; - } - } - - /* If the list went empty free it up */ - if (list_isempty(pim_ifp->sec_addr_list)) { - list_free(pim_ifp->sec_addr_list); - pim_ifp->sec_addr_list = NULL; + /* Drop stale entries */ + for (ALL_LIST_ELEMENTS(pim_ifp->sec_addr_list, node, nextnode, + sec_addr)) { + if (sec_addr->flags & PIM_SEC_ADDRF_STALE) { + pim_sec_addr_del(pim_ifp, sec_addr); + changed = 1; } } diff --git a/pimd/pim_join.c b/pimd/pim_join.c index 9796f580ce..c60e5a65aa 100644 --- a/pimd/pim_join.c +++ b/pimd/pim_join.c @@ -306,14 +306,20 @@ int pim_joinprune_recv(struct interface *ifp, struct pim_neighbor *neigh, return -8; } - sg_ch = pim_ifchannel_find(ifp, &sg); - buf += addr_offset; starg_alone = 0; recv_prune(ifp, neigh, msg_holdtime, msg_upstream_addr.u.prefix4, &sg, msg_source_flags); + /* + * So if we are receiving a S,G,RPT prune + * before we have any data for that S,G + * We need to retrieve the sg_ch after + * we parse the prune. + */ + sg_ch = pim_ifchannel_find(ifp, &sg); + /* Received SG-RPT Prune delete oif from specific S,G */ if (starg_ch && sg_ch && (msg_source_flags & PIM_RPT_BIT_MASK) diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index f6a2c92586..5886d39c19 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -218,15 +218,27 @@ static int vtysh_client_run_all(struct vtysh_client *head_client, { struct vtysh_client *client; int rc, rc_all = CMD_SUCCESS; + int correct_instance = 0, wrong_instance = 0; for (client = head_client; client; client = client->next) { rc = vtysh_client_run(client, line, fp, callback, cbarg); + if (rc == CMD_NOT_MY_INSTANCE) { + wrong_instance++; + continue; + } + correct_instance++; if (rc != CMD_SUCCESS) { if (!continue_on_err) return rc; rc_all = rc; } } + if (wrong_instance && !correct_instance && fp) { + fprintf(fp, + "%% [%s]: command ignored as it targets an instance that is not running\n", + head_client->name); + rc_all = CMD_WARNING_CONFIG_FAILED; + } return rc_all; } diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 887ea4794d..192fffd29c 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1704,7 +1704,7 @@ static int netlink_macfdb_change(struct sockaddr_nl *snl, struct nlmsghdr *h, return 0; } - if (RTA_PAYLOAD(tb[NDA_LLADDR]) != ETHER_ADDR_LEN) { + if (RTA_PAYLOAD(tb[NDA_LLADDR]) != ETH_ALEN) { zlog_warn( "%s family %s IF %s(%u) brIF %u - LLADDR is not MAC, len %lu", nl_msg_type_to_str(h->nlmsg_type), @@ -1714,7 +1714,7 @@ static int netlink_macfdb_change(struct sockaddr_nl *snl, struct nlmsghdr *h, return 0; } - memcpy(&mac, RTA_DATA(tb[NDA_LLADDR]), ETHER_ADDR_LEN); + memcpy(&mac, RTA_DATA(tb[NDA_LLADDR]), ETH_ALEN); if ((NDA_VLAN <= NDA_MAX) && tb[NDA_VLAN]) { vid_present = 1; @@ -2033,7 +2033,7 @@ static int netlink_ipneigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h, if (h->nlmsg_type == RTM_NEWNEIGH) { if (tb[NDA_LLADDR]) { - if (RTA_PAYLOAD(tb[NDA_LLADDR]) != ETHER_ADDR_LEN) { + if (RTA_PAYLOAD(tb[NDA_LLADDR]) != ETH_ALEN) { zlog_warn( "%s family %s IF %s(%u) - LLADDR is not MAC, len %lu", nl_msg_type_to_str(h->nlmsg_type), @@ -2044,7 +2044,7 @@ static int netlink_ipneigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h, } mac_present = 1; - memcpy(&mac, RTA_DATA(tb[NDA_LLADDR]), ETHER_ADDR_LEN); + memcpy(&mac, RTA_DATA(tb[NDA_LLADDR]), ETH_ALEN); } ext_learned = (ndm->ndm_flags & NTF_EXT_LEARNED) ? 1 : 0; diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index c96f073064..7d265af309 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -469,7 +469,7 @@ static int zvni_macip_send_msg_to_client(struct zebra_vrf *zvrf, vni_t vni, zserv_create_header(s, cmd, zvrf_id(zvrf)); stream_putl(s, vni); - stream_put(s, macaddr->octet, ETHER_ADDR_LEN); + stream_put(s, macaddr->octet, ETH_ALEN); if (ip) { ipa_len = 0; if (IS_IPADDR_V4(ip)) @@ -776,18 +776,9 @@ static void zvni_install_neigh_hash(struct hash_backet *backet, void *ctxt) static unsigned int mac_hash_keymake(void *p) { zebra_mac_t *pmac = p; - char *pnt = (char *)pmac->macaddr.octet; - unsigned int key = 0; - int c = 0; + const void *pnt = (void *)pmac->macaddr.octet; - key += pnt[c]; - key += pnt[c + 1]; - key += pnt[c + 2]; - key += pnt[c + 3]; - key += pnt[c + 4]; - key += pnt[c + 5]; - - return (key); + return jhash(pnt, ETH_ALEN, 0xa5a5a55a); } /* @@ -805,7 +796,7 @@ static int mac_cmp(const void *p1, const void *p2) return 0; return (memcmp(pmac1->macaddr.octet, pmac2->macaddr.octet, - ETHER_ADDR_LEN) + ETH_ALEN) == 0); } @@ -832,7 +823,7 @@ static zebra_mac_t *zvni_mac_add(zebra_vni_t *zvni, struct ethaddr *macaddr) zebra_mac_t *mac = NULL; memset(&tmp_mac, 0, sizeof(zebra_mac_t)); - memcpy(&tmp_mac.macaddr, macaddr, ETHER_ADDR_LEN); + memcpy(&tmp_mac.macaddr, macaddr, ETH_ALEN); mac = hash_get(zvni->mac_table, &tmp_mac, zvni_mac_alloc); assert(mac); @@ -940,7 +931,7 @@ static zebra_mac_t *zvni_mac_lookup(zebra_vni_t *zvni, struct ethaddr *mac) zebra_mac_t *pmac; memset(&tmp, 0, sizeof(tmp)); - memcpy(&tmp.macaddr, mac, ETHER_ADDR_LEN); + memcpy(&tmp.macaddr, mac, ETH_ALEN); pmac = hash_lookup(zvni->mac_table, &tmp); return pmac; @@ -1976,7 +1967,7 @@ int zebra_vxlan_local_neigh_add_update(struct interface *ifp, if (n) { if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL)) { if (memcmp(n->emac.octet, macaddr->octet, - ETHER_ADDR_LEN) + ETH_ALEN) == 0) { if (n->ifindex == ifp->ifindex) /* we're not interested in whatever has @@ -2022,7 +2013,7 @@ int zebra_vxlan_local_neigh_add_update(struct interface *ifp, /* Set "local" forwarding info. */ SET_FLAG(n->flags, ZEBRA_NEIGH_LOCAL); - memcpy(&n->emac, macaddr, ETHER_ADDR_LEN); + memcpy(&n->emac, macaddr, ETH_ALEN); n->ifindex = ifp->ifindex; /* Inform BGP if required. */ @@ -2062,14 +2053,14 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, int sock, u_short length, n = NULL; memset(&ip, 0, sizeof(ip)); vni = (vni_t)stream_getl(s); - stream_get(&macaddr.octet, s, ETHER_ADDR_LEN); + stream_get(&macaddr.octet, s, ETH_ALEN); ipa_len = stream_getl(s); if (ipa_len) { ip.ipa_type = (ipa_len == IPV4_MAX_BYTELEN) ? IPADDR_V4 : IPADDR_V6; stream_get(&ip.ip.addr, s, ipa_len); } - l += 4 + ETHER_ADDR_LEN + 4 + ipa_len; + l += 4 + ETH_ALEN + 4 + ipa_len; vtep_ip.s_addr = stream_get_ipv4(s); l += IPV4_MAX_BYTELEN; @@ -2148,7 +2139,7 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, int sock, u_short length, */ if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE) && (memcmp(n->emac.octet, macaddr.octet, - ETHER_ADDR_LEN) + ETH_ALEN) == 0)) { zvni_neigh_uninstall(zvni, n); zvni_neigh_del(zvni, n); @@ -2205,14 +2196,14 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, int sock, u_short length, n = NULL; memset(&ip, 0, sizeof(ip)); vni = (vni_t)stream_getl(s); - stream_get(&macaddr.octet, s, ETHER_ADDR_LEN); + stream_get(&macaddr.octet, s, ETH_ALEN); ipa_len = stream_getl(s); if (ipa_len) { ip.ipa_type = (ipa_len == IPV4_MAX_BYTELEN) ? IPADDR_V4 : IPADDR_V6; stream_get(&ip.ip.addr, s, ipa_len); } - l += 4 + ETHER_ADDR_LEN + 4 + ipa_len; + l += 4 + ETH_ALEN + 4 + ipa_len; vtep_ip.s_addr = stream_get_ipv4(s); l += IPV4_MAX_BYTELEN; @@ -2363,7 +2354,7 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, int sock, u_short length, /* Set "remote" forwarding info. */ UNSET_FLAG(n->flags, ZEBRA_NEIGH_LOCAL); /* TODO: Handle MAC change. */ - memcpy(&n->emac, &macaddr, ETHER_ADDR_LEN); + memcpy(&n->emac, &macaddr, ETH_ALEN); n->r_vtep_ip = vtep_ip; SET_FLAG(n->flags, ZEBRA_NEIGH_REMOTE); |
