From 22e63104d264d8d8724b7d6c98991fe540183f6b Mon Sep 17 00:00:00 2001 From: vivek Date: Tue, 28 Nov 2017 23:40:30 -0800 Subject: [PATCH 01/24] bgpd, zebra: Handle EVPN router MAC per next hop Ensure that when EVPN routes are installed into zebra, the router MAC is passed per next hop and appropriately handled. This is required for proper multipath operation. Ticket: CM-18999 Reviewed By: Testing Done: Verified failed scenario, other manual tests Signed-off-by: Vivek Venkatraman --- bgpd/bgp_zebra.c | 4 ++-- lib/zclient.c | 14 ++++++++++---- lib/zclient.h | 4 ++-- zebra/connected.c | 4 ++-- zebra/kernel_socket.c | 8 ++++---- zebra/redistribute.c | 2 +- zebra/rib.h | 3 +-- zebra/rt_netlink.c | 4 ++-- zebra/zapi_msg.c | 11 +++++------ zebra/zebra_rib.c | 5 ++--- zebra/zebra_vxlan.c | 37 ++++++++++++++++--------------------- zebra/zebra_vxlan.h | 1 - 12 files changed, 47 insertions(+), 50 deletions(-) diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 93a509c219..7bb01b60aa 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1207,7 +1207,6 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, /* Make Zebra API structure. */ memset(&api, 0, sizeof(api)); - memcpy(&api.rmac, &(info->attr->rmac), sizeof(struct ethaddr)); api.vrf_id = bgp->vrf_id; api.type = ZEBRA_ROUTE_BGP; api.safi = safi; @@ -1376,6 +1375,8 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, api_nh->label_num = 1; api_nh->labels[0] = label; } + memcpy(&api_nh->rmac, &(mpinfo->attr->rmac), + sizeof(struct ethaddr)); valid_nh_count++; } @@ -1500,7 +1501,6 @@ void bgp_zebra_withdraw(struct prefix *p, struct bgp_info *info, } memset(&api, 0, sizeof(api)); - memcpy(&api.rmac, &(info->attr->rmac), sizeof(struct ethaddr)); api.vrf_id = bgp->vrf_id; api.type = ZEBRA_ROUTE_BGP; api.safi = safi; diff --git a/lib/zclient.c b/lib/zclient.c index cb39099fc2..05bd907589 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -975,8 +975,6 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api) stream_putl(s, api->flags); stream_putc(s, api->message); stream_putc(s, api->safi); - if (CHECK_FLAG(api->flags, ZEBRA_FLAG_EVPN_ROUTE)) - stream_put(s, &(api->rmac), sizeof(struct ethaddr)); /* Put prefix information. */ stream_putc(s, api->prefix.family); @@ -1061,6 +1059,11 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api) api_nh->label_num * sizeof(mpls_label_t)); } + + /* Router MAC for EVPN routes. */ + if (CHECK_FLAG(api->flags, ZEBRA_FLAG_EVPN_ROUTE)) + stream_put(s, &(api_nh->rmac), + sizeof(struct ethaddr)); } } @@ -1101,8 +1104,6 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api) STREAM_GETL(s, api->flags); STREAM_GETC(s, api->message); STREAM_GETC(s, api->safi); - if (CHECK_FLAG(api->flags, ZEBRA_FLAG_EVPN_ROUTE)) - STREAM_GET(&(api->rmac), s, sizeof(struct ethaddr)); /* Prefix. */ STREAM_GETC(s, api->prefix.family); @@ -1212,6 +1213,11 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api) api_nh->label_num * sizeof(mpls_label_t)); } + + /* Router MAC for EVPN routes. */ + if (CHECK_FLAG(api->flags, ZEBRA_FLAG_EVPN_ROUTE)) + stream_get(&(api_nh->rmac), s, + sizeof(struct ethaddr)); } } diff --git a/lib/zclient.h b/lib/zclient.h index 8d26b7fe59..c5eaf9c0fd 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -302,6 +302,8 @@ struct zapi_nexthop { /* MPLS labels for BGP-LU or Segment Routing */ uint8_t label_num; mpls_label_t labels[MPLS_MAX_LABELS]; + + struct ethaddr rmac; }; /* @@ -342,8 +344,6 @@ struct zapi_route { vrf_id_t vrf_id; uint32_t tableid; - - struct ethaddr rmac; }; /* Zebra IPv4 route message API. */ diff --git a/zebra/connected.c b/zebra/connected.c index 23f2f666a0..a9a4dfe08f 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -403,10 +403,10 @@ void connected_down(struct interface *ifp, struct connected *ifc) * head. */ rib_delete(afi, SAFI_UNICAST, ifp->vrf_id, ZEBRA_ROUTE_CONNECT, 0, 0, - &p, NULL, &nh, 0, 0, false, NULL); + &p, NULL, &nh, 0, 0, false); rib_delete(afi, SAFI_MULTICAST, ifp->vrf_id, ZEBRA_ROUTE_CONNECT, 0, 0, - &p, NULL, &nh, 0, 0, false, NULL); + &p, NULL, &nh, 0, 0, false); if (IS_ZEBRA_DEBUG_RIB_DETAILED) { char buf[PREFIX_STRLEN]; diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index e60e05bcdf..b85c4748c4 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -1043,7 +1043,7 @@ void rtm_read(struct rt_msghdr *rtm) if (rtm->rtm_type == RTM_CHANGE) rib_delete(AFI_IP, SAFI_UNICAST, VRF_DEFAULT, ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL, - NULL, 0, 0, true, NULL); + NULL, 0, 0, true); if (!nh.type) { nh.type = NEXTHOP_TYPE_IPV4; @@ -1058,7 +1058,7 @@ void rtm_read(struct rt_msghdr *rtm) else rib_delete(AFI_IP, SAFI_UNICAST, VRF_DEFAULT, ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL, - &nh, 0, 0, true, NULL); + &nh, 0, 0, true); } if (dest.sa.sa_family == AF_INET6) { /* One day we might have a debug section here like one in the @@ -1089,7 +1089,7 @@ void rtm_read(struct rt_msghdr *rtm) if (rtm->rtm_type == RTM_CHANGE) rib_delete(AFI_IP6, SAFI_UNICAST, VRF_DEFAULT, ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL, - NULL, 0, 0, true, NULL); + NULL, 0, 0, true); if (!nh.type) { nh.type = ifindex ? NEXTHOP_TYPE_IPV6_IFINDEX @@ -1106,7 +1106,7 @@ void rtm_read(struct rt_msghdr *rtm) else rib_delete(AFI_IP6, SAFI_UNICAST, VRF_DEFAULT, ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL, - &nh, 0, 0, true, NULL); + &nh, 0, 0, true); } } diff --git a/zebra/redistribute.c b/zebra/redistribute.c index 810ee33839..5a6565aec9 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -592,7 +592,7 @@ int zebra_del_import_table_entry(struct route_node *rn, struct route_entry *re) rib_delete(afi, SAFI_UNICAST, re->vrf_id, ZEBRA_ROUTE_TABLE, re->table, re->flags, &p, NULL, re->ng.nexthop, - zebrad.rtm_table_default, re->metric, false, NULL); + zebrad.rtm_table_default, re->metric, false); return 0; } diff --git a/zebra/rib.h b/zebra/rib.h index d68bf787c0..7b9e6d56a7 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -313,8 +313,7 @@ extern int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p, extern void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, unsigned short instance, int flags, struct prefix *p, struct prefix_ipv6 *src_p, const struct nexthop *nh, - uint32_t table_id, uint32_t metric, bool fromkernel, - struct ethaddr *rmac); + uint32_t table_id, uint32_t metric, bool fromkernel); extern struct route_entry *rib_match(afi_t afi, safi_t safi, vrf_id_t vrf_id, union g_addr *addr, diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index a35dc9a177..1d43567ce3 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -613,12 +613,12 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl, if (gate) memcpy(&nh.gate, gate, sz); rib_delete(afi, SAFI_UNICAST, vrf_id, proto, 0, flags, - &p, NULL, &nh, table, metric, true, NULL); + &p, NULL, &nh, table, metric, true); } else { /* XXX: need to compare the entire list of nexthops * here for NLM_F_APPEND stupidity */ rib_delete(afi, SAFI_UNICAST, vrf_id, proto, 0, flags, - &p, NULL, NULL, table, metric, true, NULL); + &p, NULL, NULL, table, metric, true); } } diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 2ff660b3f9..6bd12391db 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1382,7 +1382,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS) &(api_nh->gate.ipv4), sizeof(struct in_addr)); zebra_vxlan_evpn_vrf_route_add( - vrf_id, &api.rmac, &vtep_ip, + vrf_id, &api_nh->rmac, &vtep_ip, &api.prefix); } break; @@ -1415,7 +1415,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS) &(api_nh->gate.ipv6), sizeof(struct in6_addr)); zebra_vxlan_evpn_vrf_route_add( - vrf_id, &api.rmac, &vtep_ip, + vrf_id, &api_nh->rmac, &vtep_ip, &api.prefix); } break; @@ -1522,7 +1522,7 @@ static void zread_route_del(ZAPI_HANDLER_ARGS) rib_delete(afi, api.safi, zvrf_id(zvrf), api.type, api.instance, api.flags, &api.prefix, src_p, NULL, table_id, api.metric, - false, &api.rmac); + false); /* Stats */ switch (api.prefix.family) { @@ -1724,7 +1724,7 @@ static void zread_ipv4_delete(ZAPI_HANDLER_ARGS) table_id = zvrf->table_id; rib_delete(AFI_IP, api.safi, zvrf_id(zvrf), api.type, api.instance, - api.flags, &p, NULL, NULL, table_id, 0, false, NULL); + api.flags, &p, NULL, NULL, table_id, 0, false); client->v4_route_del_cnt++; stream_failure: @@ -2148,8 +2148,7 @@ static void zread_ipv6_delete(ZAPI_HANDLER_ARGS) src_pp = NULL; rib_delete(AFI_IP6, api.safi, zvrf_id(zvrf), api.type, api.instance, - api.flags, &p, src_pp, NULL, client->rtm_table, 0, false, - NULL); + api.flags, &p, src_pp, NULL, client->rtm_table, 0, false); client->v6_route_del_cnt++; diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 67832f2d3f..7ec640164a 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2394,8 +2394,7 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p, void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, unsigned short instance, int flags, struct prefix *p, struct prefix_ipv6 *src_p, const struct nexthop *nh, - uint32_t table_id, uint32_t metric, bool fromkernel, - struct ethaddr *rmac) + uint32_t table_id, uint32_t metric, bool fromkernel) { struct route_table *table; struct route_node *rn; @@ -2569,7 +2568,7 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, &(tmp_nh->gate.ipv6), sizeof(struct in6_addr)); } - zebra_vxlan_evpn_vrf_route_del(re->vrf_id, rmac, + zebra_vxlan_evpn_vrf_route_del(re->vrf_id, &vtep_ip, p); } } diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 6e901a0457..af01cd9c70 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -3238,15 +3238,9 @@ static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni, struct ethaddr *rmac, /* handle rmac delete */ -static int zl3vni_remote_rmac_del(zebra_l3vni_t *zl3vni, struct ethaddr *rmac, +static void zl3vni_remote_rmac_del(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac, struct prefix *host_prefix) { - zebra_mac_t *zrmac = NULL; - - zrmac = zl3vni_rmac_lookup(zl3vni, rmac); - if (!zrmac) - return -1; - host_list_delete_host(zrmac->host_list, host_prefix); if (list_isempty(zrmac->host_list)) { @@ -3256,7 +3250,6 @@ static int zl3vni_remote_rmac_del(zebra_l3vni_t *zl3vni, struct ethaddr *rmac, /* del the rmac entry */ zl3vni_rmac_del(zl3vni, zrmac); } - return 0; } /* @@ -3394,15 +3387,9 @@ static int zl3vni_remote_nh_add(zebra_l3vni_t *zl3vni, struct ipaddr *vtep_ip, } /* handle nh neigh delete */ -static int zl3vni_remote_nh_del(zebra_l3vni_t *zl3vni, struct ipaddr *vtep_ip, - struct prefix *host_prefix) +static void zl3vni_remote_nh_del(zebra_l3vni_t *zl3vni, zebra_neigh_t *nh, + struct prefix *host_prefix) { - zebra_neigh_t *nh = NULL; - - nh = zl3vni_nh_lookup(zl3vni, vtep_ip); - if (!nh) - return -1; - host_list_delete_host(nh->host_list, host_prefix); if (list_isempty(nh->host_list)) { @@ -3412,8 +3399,6 @@ static int zl3vni_remote_nh_del(zebra_l3vni_t *zl3vni, struct ipaddr *vtep_ip, /* delete the nh entry */ zl3vni_nh_del(zl3vni, nh); } - - return 0; } /* handle neigh update from kernel - the only thing of interest is to @@ -3971,21 +3956,31 @@ void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id, struct ethaddr *rmac, } /* handle evpn vrf route delete */ -void zebra_vxlan_evpn_vrf_route_del(vrf_id_t vrf_id, struct ethaddr *rmac, +void zebra_vxlan_evpn_vrf_route_del(vrf_id_t vrf_id, struct ipaddr *vtep_ip, struct prefix *host_prefix) { zebra_l3vni_t *zl3vni = NULL; + zebra_neigh_t *nh = NULL; + zebra_mac_t *zrmac = NULL; zl3vni = zl3vni_from_vrf(vrf_id); if (!zl3vni) return; + /* find the next hop entry and rmac entry */ + nh = zl3vni_nh_lookup(zl3vni, vtep_ip); + if (!nh) + return; + zrmac = zl3vni_rmac_lookup(zl3vni, &nh->emac); + /* delete the next hop entry */ - zl3vni_remote_nh_del(zl3vni, vtep_ip, host_prefix); + zl3vni_remote_nh_del(zl3vni, nh, host_prefix); /* delete the rmac entry */ - zl3vni_remote_rmac_del(zl3vni, rmac, host_prefix); + if (zrmac) + zl3vni_remote_rmac_del(zl3vni, zrmac, host_prefix); + } void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty, vni_t l3vni, diff --git a/zebra/zebra_vxlan.h b/zebra/zebra_vxlan.h index 6153c7d7e3..34d1152751 100644 --- a/zebra/zebra_vxlan.h +++ b/zebra/zebra_vxlan.h @@ -160,7 +160,6 @@ extern void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id, struct ipaddr *ip, struct prefix *host_prefix); extern void zebra_vxlan_evpn_vrf_route_del(vrf_id_t vrf_id, - struct ethaddr *rmac, struct ipaddr *vtep_ip, struct prefix *host_prefix); From 9a55f79a267e3bc790b8d643473de32fa3719652 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 12 Apr 2018 13:27:36 -0400 Subject: [PATCH 02/24] pbrd, vtysh: Limit range to actual 1-700 The range for sequence numbers needs to be limited by the range we have currently choosen for rule ranges. Ticket: CM-20562 Signed-off-by: Donald Sharp --- pbrd/pbr_vty.c | 4 ++-- vtysh/vtysh.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index ba5c49ad5c..b7d2b1a928 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -38,7 +38,7 @@ #include "pbrd/pbr_vty_clippy.c" #endif -DEFUN_NOSH(pbr_map, pbr_map_cmd, "pbr-map WORD seq (1-1000)", +DEFUN_NOSH(pbr_map, pbr_map_cmd, "pbr-map WORD seq (1-700)", "Create pbr-map or enter pbr-map command mode\n" "The name of the PBR MAP\n" "Sequence to insert in existing pbr-map entry\n" @@ -54,7 +54,7 @@ DEFUN_NOSH(pbr_map, pbr_map_cmd, "pbr-map WORD seq (1-1000)", return CMD_SUCCESS; } -DEFUN_NOSH(no_pbr_map, no_pbr_map_cmd, "no pbr-map WORD [seq (1-65535)]", +DEFUN_NOSH(no_pbr_map, no_pbr_map_cmd, "no pbr-map WORD [seq (1-700)]", NO_STR "Delete pbr-map\n" "The name of the PBR MAP\n" diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 867dc9cd15..a682b9a774 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -1537,7 +1537,7 @@ DEFUNSH(VTYSH_RMAP, vtysh_route_map, vtysh_route_map_cmd, } DEFUNSH(VTYSH_PBRD, vtysh_pbr_map, vtysh_pbr_map_cmd, - "pbr-map NAME seq (1-1000)", + "pbr-map NAME seq (1-700)", "Create pbr-map or enter pbr-map command mode\n" "The name of the PBR MAP\n" "Sequence to insert to/delete from existing pbr-map entry\n" @@ -1547,7 +1547,7 @@ DEFUNSH(VTYSH_PBRD, vtysh_pbr_map, vtysh_pbr_map_cmd, return CMD_SUCCESS; } -DEFSH(VTYSH_PBRD, vtysh_no_pbr_map_cmd, "no pbr-map WORD [seq (1-65535)]", +DEFSH(VTYSH_PBRD, vtysh_no_pbr_map_cmd, "no pbr-map WORD [seq (1-700)]", NO_STR "Delete pbr-map\n" "The name of the PBR MAP\n" From 9f46cc36aa35e2dc68204e554fa137465baafe07 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 3 Apr 2018 16:25:13 -0400 Subject: [PATCH 03/24] lib: move ip node above vrf node for config order VRF static route commands adopt global static config if static config is placed after a vrf context with no separator, workaround by always writing static route config before vrf config Signed-off-by: Quentin Young --- lib/command.c | 2 +- lib/command.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/command.c b/lib/command.c index 2744061b5a..e0701aa412 100644 --- a/lib/command.c +++ b/lib/command.c @@ -85,6 +85,7 @@ const char *node_names[] = { "keychain", // KEYCHAIN_NODE, "keychain key", // KEYCHAIN_KEY_NODE, "logical-router", // LOGICALROUTER_NODE, + "static ip", // IP_NODE, "vrf", // VRF_NODE, "interface", // INTERFACE_NODE, "nexthop-group", // NH_GROUP_NODE, @@ -119,7 +120,6 @@ const char *node_names[] = { "ldp l2vpn", // LDP_L2VPN_NODE, "ldp", // LDP_PSEUDOWIRE_NODE, "isis", // ISIS_NODE, - "static ip", // IP_NODE, "ipv4 access list", // ACCESS_NODE, "ipv4 prefix list", // PREFIX_NODE, "ipv6 access list", // ACCESS_IPV6_NODE, diff --git a/lib/command.h b/lib/command.h index f18de3417c..9ba53e0907 100644 --- a/lib/command.h +++ b/lib/command.h @@ -85,6 +85,7 @@ enum node_type { KEYCHAIN_NODE, /* Key-chain node. */ KEYCHAIN_KEY_NODE, /* Key-chain key node. */ LOGICALROUTER_NODE, /* Logical-Router node. */ + IP_NODE, /* Static ip route node. */ VRF_NODE, /* VRF mode node. */ INTERFACE_NODE, /* Interface mode node. */ NH_GROUP_NODE, /* Nexthop-Group mode node. */ @@ -119,7 +120,6 @@ enum node_type { LDP_L2VPN_NODE, /* LDP L2VPN node */ LDP_PSEUDOWIRE_NODE, /* LDP Pseudowire node */ ISIS_NODE, /* ISIS protocol mode */ - IP_NODE, /* Static ip route node. */ ACCESS_NODE, /* Access list node. */ PREFIX_NODE, /* Prefix list node. */ ACCESS_IPV6_NODE, /* Access list node. */ From 0204baa87630b210c71d9ae0e2569cff0fb0539b Mon Sep 17 00:00:00 2001 From: Daniel Walton Date: Sat, 5 Aug 2017 00:39:56 +0400 Subject: [PATCH 04/24] watchfrr always writes 'log syslog informational' to the config Signed-off-by: Daniel Walton Reviewed-by: Dave Olson Ticket: CM-16501 --- lib/command.c | 191 +++++++++++++++++++++++++++----------------------- 1 file changed, 103 insertions(+), 88 deletions(-) diff --git a/lib/command.c b/lib/command.c index e0701aa412..d0417408b2 100644 --- a/lib/command.c +++ b/lib/command.c @@ -529,88 +529,96 @@ static int config_write_host(struct vty *vty) if (cmd_domainname_get()) vty_out(vty, "domainname %s\n", cmd_domainname_get()); - if (host.encrypt) { - if (host.password_encrypt) - vty_out(vty, "password 8 %s\n", host.password_encrypt); - if (host.enable_encrypt) - vty_out(vty, "enable password 8 %s\n", - host.enable_encrypt); - } else { - if (host.password) - vty_out(vty, "password %s\n", host.password); - if (host.enable) - vty_out(vty, "enable password %s\n", host.enable); + /* The following are all configuration commands that are not sent to + * watchfrr. For instance watchfrr is hardcoded to log to syslog so + * we would always display 'log syslog informational' in the config + * which would cause other daemons to then switch to syslog when they + * parse frr.conf. + */ + if (strcmp(zlog_default->protoname, "WATCHFRR")) { + if (host.encrypt) { + if (host.password_encrypt) + vty_out(vty, "password 8 %s\n", host.password_encrypt); + if (host.enable_encrypt) + vty_out(vty, "enable password 8 %s\n", + host.enable_encrypt); + } else { + if (host.password) + vty_out(vty, "password %s\n", host.password); + if (host.enable) + vty_out(vty, "enable password %s\n", host.enable); + } + + if (zlog_default->default_lvl != LOG_DEBUG) { + vty_out(vty, "! N.B. The 'log trap' command is deprecated.\n"); + vty_out(vty, "log trap %s\n", + zlog_priority[zlog_default->default_lvl]); + } + + if (host.logfile + && (zlog_default->maxlvl[ZLOG_DEST_FILE] != ZLOG_DISABLED)) { + vty_out(vty, "log file %s", host.logfile); + if (zlog_default->maxlvl[ZLOG_DEST_FILE] + != zlog_default->default_lvl) + vty_out(vty, " %s", + zlog_priority + [zlog_default->maxlvl[ZLOG_DEST_FILE]]); + vty_out(vty, "\n"); + } + + if (zlog_default->maxlvl[ZLOG_DEST_STDOUT] != ZLOG_DISABLED) { + vty_out(vty, "log stdout"); + if (zlog_default->maxlvl[ZLOG_DEST_STDOUT] + != zlog_default->default_lvl) + vty_out(vty, " %s", + zlog_priority[zlog_default->maxlvl + [ZLOG_DEST_STDOUT]]); + vty_out(vty, "\n"); + } + + if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] == ZLOG_DISABLED) + vty_out(vty, "no log monitor\n"); + else if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] + != zlog_default->default_lvl) + vty_out(vty, "log monitor %s\n", + zlog_priority[zlog_default->maxlvl[ZLOG_DEST_MONITOR]]); + + if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] != ZLOG_DISABLED) { + vty_out(vty, "log syslog"); + if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] + != zlog_default->default_lvl) + vty_out(vty, " %s", + zlog_priority[zlog_default->maxlvl + [ZLOG_DEST_SYSLOG]]); + vty_out(vty, "\n"); + } + + if (zlog_default->facility != LOG_DAEMON) + vty_out(vty, "log facility %s\n", + facility_name(zlog_default->facility)); + + if (zlog_default->record_priority == 1) + vty_out(vty, "log record-priority\n"); + + if (zlog_default->timestamp_precision > 0) + vty_out(vty, "log timestamp precision %d\n", + zlog_default->timestamp_precision); + + if (host.advanced) + vty_out(vty, "service advanced-vty\n"); + + if (host.encrypt) + vty_out(vty, "service password-encryption\n"); + + if (host.lines >= 0) + vty_out(vty, "service terminal-length %d\n", host.lines); + + if (host.motdfile) + vty_out(vty, "banner motd file %s\n", host.motdfile); + else if (!host.motd) + vty_out(vty, "no banner motd\n"); } - if (zlog_default->default_lvl != LOG_DEBUG) { - vty_out(vty, "! N.B. The 'log trap' command is deprecated.\n"); - vty_out(vty, "log trap %s\n", - zlog_priority[zlog_default->default_lvl]); - } - - if (host.logfile - && (zlog_default->maxlvl[ZLOG_DEST_FILE] != ZLOG_DISABLED)) { - vty_out(vty, "log file %s", host.logfile); - if (zlog_default->maxlvl[ZLOG_DEST_FILE] - != zlog_default->default_lvl) - vty_out(vty, " %s", - zlog_priority - [zlog_default->maxlvl[ZLOG_DEST_FILE]]); - vty_out(vty, "\n"); - } - - if (zlog_default->maxlvl[ZLOG_DEST_STDOUT] != ZLOG_DISABLED) { - vty_out(vty, "log stdout"); - if (zlog_default->maxlvl[ZLOG_DEST_STDOUT] - != zlog_default->default_lvl) - vty_out(vty, " %s", - zlog_priority[zlog_default->maxlvl - [ZLOG_DEST_STDOUT]]); - vty_out(vty, "\n"); - } - - if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] == ZLOG_DISABLED) - vty_out(vty, "no log monitor\n"); - else if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] - != zlog_default->default_lvl) - vty_out(vty, "log monitor %s\n", - zlog_priority[zlog_default->maxlvl[ZLOG_DEST_MONITOR]]); - - if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] != ZLOG_DISABLED) { - vty_out(vty, "log syslog"); - if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] - != zlog_default->default_lvl) - vty_out(vty, " %s", - zlog_priority[zlog_default->maxlvl - [ZLOG_DEST_SYSLOG]]); - vty_out(vty, "\n"); - } - - if (zlog_default->facility != LOG_DAEMON) - vty_out(vty, "log facility %s\n", - facility_name(zlog_default->facility)); - - if (zlog_default->record_priority == 1) - vty_out(vty, "log record-priority\n"); - - if (zlog_default->timestamp_precision > 0) - vty_out(vty, "log timestamp precision %d\n", - zlog_default->timestamp_precision); - - if (host.advanced) - vty_out(vty, "service advanced-vty\n"); - - if (host.encrypt) - vty_out(vty, "service password-encryption\n"); - - if (host.lines >= 0) - vty_out(vty, "service terminal-length %d\n", host.lines); - - if (host.motdfile) - vty_out(vty, "banner motd file %s\n", host.motdfile); - else if (!host.motd) - vty_out(vty, "no banner motd\n"); - if (debug_memstats_at_exit) vty_out(vty, "!\ndebug memstats-at-exit\n"); @@ -2304,7 +2312,7 @@ static int set_log_file(struct vty *vty, const char *fname, int loglevel) #if defined(HAVE_CUMULUS) if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] != ZLOG_DISABLED) - zlog_default->maxlvl[ZLOG_DEST_SYSLOG] = ZLOG_DISABLED; + zlog_set_level(ZLOG_DEST_SYSLOG, ZLOG_DISABLED); #endif return CMD_SUCCESS; } @@ -2330,6 +2338,16 @@ DEFUN (config_log_file, zlog_default->default_lvl); } +static void disable_log_file() +{ + zlog_reset_file(); + + if (host.logfile) + XFREE(MTYPE_HOST, host.logfile); + + host.logfile = NULL; +} + DEFUN (no_config_log_file, no_config_log_file_cmd, "no log file [FILENAME [LEVEL]]", @@ -2339,13 +2357,7 @@ DEFUN (no_config_log_file, "Logging file name\n" "Logging level\n") { - zlog_reset_file(); - - if (host.logfile) - XFREE(MTYPE_HOST, host.logfile); - - host.logfile = NULL; - + disable_log_file(); return CMD_SUCCESS; } @@ -2357,6 +2369,9 @@ DEFUN (config_log_syslog, LOG_LEVEL_DESC) { int idx_log_levels = 2; + + disable_log_file(); + if (argc == 3) { int level; if ((level = level_match(argv[idx_log_levels]->arg)) From f50dc5e6070383e803dc3441aedd5a435974c762 Mon Sep 17 00:00:00 2001 From: Mitesh Kanjariya Date: Sun, 8 Apr 2018 21:04:11 -0700 Subject: [PATCH 05/24] zebra: remote RMAC for EVPN ipv6 hosts should be programmed against the ipv4 nexthop For ipv6 host, the next hop is conevrted to ipv6 mapped address. However, the remote rmac should still be programmed with the ipv4 address. This is how the entries will look in the kernel for ipv6 hosts routing. vrf routing table: ipv6 -> ipv6_mapped remote vtep on l3vni SVI neigh table: ipv6_mapped remote vtep -> remote RMAC bridge fdb: remote rmac -> ipv4 vtep tunnel Signed-off-by: Mitesh Kanjariya --- lib/ipaddr.h | 10 ++++++++++ zebra/zebra_vxlan.c | 28 ++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/lib/ipaddr.h b/lib/ipaddr.h index 33591cb4e7..7f2d06548b 100644 --- a/lib/ipaddr.h +++ b/lib/ipaddr.h @@ -102,4 +102,14 @@ static inline void ipv4_to_ipv4_mapped_ipv6(struct in6_addr *in6, memcpy((char *)in6 + 12, &in, sizeof(struct in_addr)); } +/* + * convert an ipv4 mapped ipv6 address back to ipv4 address + */ +static inline void ipv4_mapped_ipv6_to_ipv4(struct in6_addr *in6, + struct in_addr *in) +{ + memset(in, 0, sizeof(struct in_addr)); + memcpy(in, (char *)in6 + 12, sizeof(struct in_addr)); +} + #endif /* __IPADDR_H__ */ diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index af01cd9c70..6f3b5d26a1 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -3943,16 +3943,36 @@ void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id, struct ethaddr *rmac, struct prefix *host_prefix) { zebra_l3vni_t *zl3vni = NULL; + struct ipaddr ipv4_vtep; zl3vni = zl3vni_from_vrf(vrf_id); if (!zl3vni || !is_l3vni_oper_up(zl3vni)) return; - /* add the next hop neighbor */ - zl3vni_remote_nh_add(zl3vni, vtep_ip, rmac, host_prefix); + /* + * add the next hop neighbor - + * neigh to be installed is the ipv6 nexthop neigh + */ + zl3vni_remote_nh_add(zl3vni, vtep_ip, rmac, host_prefix); - /* add the rmac */ - zl3vni_remote_rmac_add(zl3vni, rmac, vtep_ip, host_prefix); + /* + * if the remote vtep is a ipv4 mapped ipv6 address convert it to ipv4 + * address. Rmac is programmed against the ipv4 vtep because we only + * support ipv4 tunnels in the h/w right now + */ + memset(&ipv4_vtep, 0, sizeof(struct ipaddr)); + ipv4_vtep.ipa_type = IPADDR_V4; + if (vtep_ip->ipa_type == IPADDR_V6) + ipv4_mapped_ipv6_to_ipv4(&vtep_ip->ipaddr_v6, + &(ipv4_vtep.ipaddr_v4)); + else + memcpy(&(ipv4_vtep.ipaddr_v4), &vtep_ip->ipaddr_v4, + sizeof(struct in_addr)); + + /* add the rmac - remote rmac to be installed is against the ipv4 + * nexthop address + */ + zl3vni_remote_rmac_add(zl3vni, rmac, &ipv4_vtep, host_prefix); } /* handle evpn vrf route delete */ From cf29971433e0ef85af3d8002541da571bee951ea Mon Sep 17 00:00:00 2001 From: Mitesh Kanjariya Date: Tue, 10 Apr 2018 01:37:21 -0700 Subject: [PATCH 06/24] zebra: vni [prefix-routes-only] should also be provided for the 'no' cmd We have a command to enable symmetric routing only for type-5 routes. This command is provided under vrf <> option in zebra as follows: vrf vni [prefix-routes-only] We need the corresponding no version of the command as well as follows: vrf no vni [prefix-routes-only] Signed-off-by: Mitesh Kanjariya --- zebra/zebra_vty.c | 12 +++++++++--- zebra/zebra_vxlan.c | 6 ++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 2ae9ac5082..e6f80f92a7 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -2798,12 +2798,14 @@ DEFUN (vrf_vni_mapping, DEFUN (no_vrf_vni_mapping, no_vrf_vni_mapping_cmd, - "no vni " CMD_VNI_RANGE, + "no vni " CMD_VNI_RANGE "[prefix-routes-only]", NO_STR "VNI corresponding to tenant VRF\n" - "VNI-ID") + "VNI-ID\n" + "prefix-routes-only\n") { int ret = 0; + int filter = 0; char err[ERR_STR_SZ]; vni_t vni = strtoul(argv[2]->arg, NULL, 10); @@ -2812,7 +2814,11 @@ DEFUN (no_vrf_vni_mapping, assert(vrf); assert(zvrf); - ret = zebra_vxlan_process_vrf_vni_cmd(zvrf, vni, err, ERR_STR_SZ, 0, 0); + if (argc == 4) + filter = 1; + + ret = zebra_vxlan_process_vrf_vni_cmd(zvrf, vni, err, + ERR_STR_SZ, filter, 0); if (ret != 0) { vty_out(vty, "%s\n", err); return CMD_WARNING; diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 6f3b5d26a1..83c241632d 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -6531,6 +6531,12 @@ int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf, vni_t vni, return -1; } + if (filter && !CHECK_FLAG(zl3vni->filter, PREFIX_ROUTES_ONLY)) { + snprintf(err, ERR_STR_SZ, + "prefix-routes-only is not set for the vni"); + return -1; + } + zebra_vxlan_process_l3vni_oper_down(zl3vni); /* delete and uninstall all rmacs */ From cc6d54769b957b3be84fcabda09332991e51eb28 Mon Sep 17 00:00:00 2001 From: Mitesh Kanjariya Date: Thu, 1 Mar 2018 17:18:34 -0800 Subject: [PATCH 07/24] bgpd/zebra: use stream_putl/getl to send VNIs Signed-off-by: Mitesh Kanjariya --- bgpd/bgp_zebra.c | 2 +- zebra/zebra_vxlan.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 7bb01b60aa..a86ea0e522 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1913,7 +1913,7 @@ int bgp_zebra_advertise_gw_macip(struct bgp *bgp, int advertise, vni_t vni) zclient_create_header(s, ZEBRA_ADVERTISE_DEFAULT_GW, bgp->vrf_id); stream_putc(s, advertise); - stream_put3(s, vni); + stream_putl(s, vni); stream_putw_at(s, 0, stream_get_endp(s)); return zclient_send_message(zclient); diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 83c241632d..efc3e8177a 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -6684,7 +6684,7 @@ void zebra_vxlan_advertise_gw_macip(ZAPI_HANDLER_ARGS) s = msg; STREAM_GETC(s, advertise); - STREAM_GET(&vni, s, 3); + STREAM_GETL(s, vni); if (!vni) { if (IS_ZEBRA_DEBUG_VXLAN) From 2dd3221735d2ac06d41e98e4d72a99a528da821d Mon Sep 17 00:00:00 2001 From: vivek Date: Wed, 1 Nov 2017 16:57:55 -0700 Subject: [PATCH 08/24] bgpd: Display table version for EVPN routes Display the table version for EVPN routes like it is done for other address families. Note that this is really relevant only for the per-VNI routing table. Signed-off-by: Vivek Venkatraman Ticket: CM-12903 --- bgpd/bgp_evpn_vty.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index c74a1bfb7c..4f3f0d5559 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -311,7 +311,7 @@ static void bgp_evpn_show_route_rd_header(struct vty *vty, } static void bgp_evpn_show_route_header(struct vty *vty, struct bgp *bgp, - json_object *json) + uint64_t tbl_ver, json_object *json) { char ri_header[] = " Network Next Hop Metric LocPrf Weight Path\n"; @@ -319,9 +319,8 @@ static void bgp_evpn_show_route_header(struct vty *vty, struct bgp *bgp, if (json) return; - - vty_out(vty, "BGP table version is 0, local router ID is %s\n", - inet_ntoa(bgp->router_id)); + vty_out(vty, "BGP table version is %" PRIu64 ", local router ID is %s\n", + tbl_ver, inet_ntoa(bgp->router_id)); vty_out(vty, "Status codes: s suppressed, d damped, h history, " "* valid, > best, i - internal\n"); @@ -494,12 +493,16 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type, { struct bgp_node *rn; struct bgp_info *ri; + struct bgp_table *table; int header = 1; + uint64_t tbl_ver; uint32_t prefix_cnt, path_cnt; prefix_cnt = path_cnt = 0; - for (rn = bgp_table_top(vpn->route_table); rn; + table = vpn->route_table; + tbl_ver = table->version; + for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; int add_prefix_to_json = 0; @@ -519,7 +522,8 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type, if (rn->info) { /* Overall header/legend displayed once. */ if (header) { - bgp_evpn_show_route_header(vty, bgp, json); + bgp_evpn_show_route_header(vty, bgp, + tbl_ver, json); header = 0; } @@ -862,6 +866,8 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, for (rn = bgp_table_top(bgp->rib[afi][SAFI_EVPN]); rn; rn = bgp_route_next(rn)) { + uint64_t tbl_ver; + if (use_json) continue; /* XXX json TODO */ @@ -872,6 +878,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, continue; rd_header = 1; + tbl_ver = table->version; for (rm = bgp_table_top(table); rm; rm = bgp_route_next(rm)) for (ri = rm->info; ri; ri = ri->next) { @@ -891,7 +898,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, json_object_int_add( json, "bgpTableVersion", - 0); + tbl_ver); json_object_string_add( json, "bgpLocalRouterId", @@ -917,7 +924,8 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, V4_HEADER_OVERLAY); else { vty_out(vty, - "BGP table version is 0, local router ID is %s\n", + "BGP table version is %" PRIu64 ", local router ID is %s\n", + tbl_ver, inet_ntoa( bgp->router_id)); vty_out(vty, @@ -2201,11 +2209,13 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type, char rd_str[RD_ADDRSTRLEN]; json_object *json_rd = NULL; /* contains routes for an RD */ int add_rd_to_json = 0; + uint64_t tbl_ver; table = (struct bgp_table *)rd_rn->info; if (table == NULL) continue; + tbl_ver = table->version; prefix_rd2str((struct prefix_rd *)&rd_rn->p, rd_str, sizeof(rd_str)); @@ -2236,6 +2246,7 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type, /* Overall header/legend displayed once. */ if (header) { bgp_evpn_show_route_header(vty, bgp, + tbl_ver, json); header = 0; } From d4f7497ebd0e7a9735d8b74d60166707119686bf Mon Sep 17 00:00:00 2001 From: Mitesh Kanjariya Date: Tue, 10 Apr 2018 03:31:05 -0700 Subject: [PATCH 09/24] bgpd: no advertise ipv6 unicast comand should unset the af_flags no advertise ipv6 unicast command should unset the corresponding af_flag in bgp_vrf rather than the vrf_flags. Signed-off-by: Mitesh Kanjariya --- bgpd/bgp_evpn_vty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 4f3f0d5559..2f0f8b34a4 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -2884,7 +2884,7 @@ DEFUN (no_bgp_evpn_advertise_type5, if (CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN], BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST)) { bgp_evpn_withdraw_type5_routes(bgp_vrf, afi, safi); - UNSET_FLAG(bgp_vrf->vrf_flags, + UNSET_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN], BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST); } } From d2a0075ac2eb4c6c9d6f2f789623ac6451d115ea Mon Sep 17 00:00:00 2001 From: Mitesh Kanjariya Date: Tue, 10 Apr 2018 03:02:24 -0700 Subject: [PATCH 10/24] bgpd: write route-map to config for advertise type5 commands We enable/disable type-5 routes by following commands: advertise ipv4 unicast [route-map ] advertise ipv6 commands [route-map ] the route-map part was writtem to conf file. Signed-off-by: Mitesh Kanjariya --- bgpd/bgp_evpn_vty.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 2f0f8b34a4..3fa2e38c00 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -4393,12 +4393,22 @@ void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi, vty_out(vty, " advertise-default-gw\n"); if (CHECK_FLAG(bgp->af_flags[AFI_L2VPN][SAFI_EVPN], - BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST)) - vty_out(vty, " advertise ipv4 unicast\n"); + BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST)) { + if (bgp->adv_cmd_rmap[AFI_IP][SAFI_UNICAST].name) + vty_out(vty, " advertise ipv4 unicast route-map %s\n", + bgp->adv_cmd_rmap[AFI_IP][SAFI_UNICAST].name); + else + vty_out(vty, " advertise ipv4 unicast\n"); + } if (CHECK_FLAG(bgp->af_flags[AFI_L2VPN][SAFI_EVPN], - BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST)) - vty_out(vty, " advertise ipv6 unicast\n"); + BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST)) { + if (bgp->adv_cmd_rmap[AFI_IP6][SAFI_UNICAST].name) + vty_out(vty, " advertise ipv6 unicast route-map %s\n", + bgp->adv_cmd_rmap[AFI_IP6][SAFI_UNICAST].name); + else + vty_out(vty, " advertise ipv6 unicast\n"); + } if (CHECK_FLAG(bgp->af_flags[AFI_L2VPN][SAFI_EVPN], BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV4)) From 7e4ed18ef5c034d09567c2d2cf26f806e134e698 Mon Sep 17 00:00:00 2001 From: Mitesh Kanjariya Date: Mon, 16 Apr 2018 01:09:03 -0700 Subject: [PATCH 11/24] bgpd: apply advertise ipv4 unicast route-map while advertising type-5 routes A newly added ipv4/ipv6 route in BGP RIB might be advertised as type-5 EVPN route. The user might have configured a route-map for advertising type-5 routes. We need to apply this route-map while advertising ipv4/ipv6 routes as type-5. Signed-off-by: Mitesh Kanjariya --- bgpd/bgp_route.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 4802a4caa5..2a4eab0adc 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2353,12 +2353,30 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn, /* advertise/withdraw type-5 routes */ if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) { if (advertise_type5_routes(bgp, afi) && new_select && - (!new_select->extra || !new_select->extra->parent)) - bgp_evpn_advertise_type5_route(bgp, &rn->p, - new_select->attr, - afi, safi); - else if (advertise_type5_routes(bgp, afi) && old_select && - (!old_select->extra || !old_select->extra->parent)) + (!new_select->extra || !new_select->extra->parent)) { + + /* apply the route-map */ + if (bgp->adv_cmd_rmap[afi][safi].map) { + int ret = 0; + + ret = + route_map_apply( + bgp->adv_cmd_rmap[afi][safi].map, + &rn->p, RMAP_BGP, new_select); + if (ret == RMAP_MATCH) + bgp_evpn_advertise_type5_route(bgp, + &rn->p, + new_select->attr, + afi, safi); + } else { + bgp_evpn_advertise_type5_route(bgp, + &rn->p, + new_select->attr, + afi, safi); + + } + } else if (advertise_type5_routes(bgp, afi) && old_select && + (!old_select->extra || !old_select->extra->parent)) bgp_evpn_withdraw_type5_route(bgp, &rn->p, afi, safi); } From 2b659f33296f425e54410ceb08741da5d5d53d00 Mon Sep 17 00:00:00 2001 From: Mitesh Kanjariya Date: Wed, 11 Apr 2018 02:29:46 -0700 Subject: [PATCH 12/24] bgpd: modify route install/withdraw logic for evpn type-5 routes in vrf We install type-5 routes as ipv4/ipv6 unicast routes in the vrf table. along with these routes, we also install the RMAC and the nexthop Neigh entries. There might be scenarios were the bestpath has changed and we are now pointing to a new nexthop with a different RMAC. As per BGP logic, we just send an update for the route and the nexthop is replaced. However, this causes problem because the RMAC and neigh entry corresponding to the previous nexthop are still lingering in the system. We need to clear those entries for proper functoning. Signed-off-by: Mitesh Kanjariya --- bgpd/bgp_route.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 2a4eab0adc..19af159be0 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2336,10 +2336,18 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn, if (new_select && new_select->type == ZEBRA_ROUTE_BGP && (new_select->sub_type == BGP_ROUTE_NORMAL || new_select->sub_type == BGP_ROUTE_AGGREGATE - || new_select->sub_type == BGP_ROUTE_IMPORTED)) + || new_select->sub_type == BGP_ROUTE_IMPORTED)) { + + /* if this is an evpn imported type-5 prefix, + * we need to withdraw the route first to clear + * the nh neigh and the RMAC entry. + */ + if (old_select && + is_route_parent_evpn(old_select)) + bgp_zebra_withdraw(p, old_select, bgp, safi); bgp_zebra_announce(rn, p, new_select, bgp, afi, safi); - else { + } else { /* Withdraw the route from the kernel. */ if (old_select && old_select->type == ZEBRA_ROUTE_BGP && (old_select->sub_type == BGP_ROUTE_NORMAL From ace295a90d6df40c4683dc82ad4004a8b2f0b002 Mon Sep 17 00:00:00 2001 From: Mitesh Kanjariya Date: Thu, 1 Mar 2018 01:47:28 -0800 Subject: [PATCH 13/24] bgpd: enable neighbor-nexthop-self for l2vpn evpn address family In the FRR implementation of EVPN, eBGP leaf-spine peering for EVPN is fully supported by allowing the next hop to be propagated and not rewritten at each hop. There are other changes also related to route import to facilitate this. However, propagating the next hop is not correct in some cases. Specifically, if the DC is comprised of multiple PODs with distinct intra-POD and inter-POD VxLAN tunnels, EVPN routes received from an adjacent POD by a border/exit leaf must be propagated into the local POD with the next hop rewritten (to self). Signed-off-by: Mitesh Kanjariya --- bgpd/bgp_route.c | 2 ++ bgpd/bgp_updgrp_packet.c | 3 +-- bgpd/bgp_vty.c | 2 ++ bgpd/bgpd.c | 37 ++++++++++++++++++++++++++++++++++++- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 19af159be0..401a7e8549 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1336,6 +1336,8 @@ static void subgroup_announce_reset_nhop(uint8_t family, struct attr *attr) } if (family == AF_INET6) memset(&attr->mp_nexthop_global, 0, IPV6_MAX_BYTELEN); + if (family == AF_EVPN) + memset(&attr->mp_nexthop_global_in, 0, BGP_ATTR_NHLEN_IPV4); } int subgroup_announce_check(struct bgp_node *rn, struct bgp_info *ri, diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c index 8ba7902a5f..cabd5b5cbd 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -467,13 +467,12 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt, nh_modified = 1; } else if ( peer->sort == BGP_PEER_EBGP - && paf->safi != SAFI_EVPN && (bgp_multiaccess_check_v4(v4nh, peer) == 0) && !CHECK_FLAG( vec->flags, BPKT_ATTRVEC_FLAGS_RMAP_NH_UNCHANGED) && !peer_af_flag_check( - peer, nhafi, paf->safi, + peer, paf->afi, paf->safi, PEER_FLAG_NEXTHOP_UNCHANGED)) { /* NOTE: not handling case where NH has new AFI */ diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index e1b050bf59..f9c4a26dc6 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -12575,6 +12575,8 @@ void bgp_vty_init(void) install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); + install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); + install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); /* "neighbor next-hop-self force" commands. */ install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index a331fad5d4..c6ad57f84a 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -711,6 +711,10 @@ struct peer_af *peer_af_create(struct peer *peer, afi_t afi, safi_t safi) af->afid = afid; af->peer = peer; + /* for l2vpn/evpn the default behaviour is nexthop-unchanged */ + if (afi == AFI_L2VPN && safi == SAFI_EVPN) + peer_af_flag_set(peer, afi, safi, PEER_FLAG_NEXTHOP_UNCHANGED); + return af; } @@ -1928,6 +1932,10 @@ static int peer_activate_af(struct peer *peer, afi_t afi, safi_t safi) } } + /* for l2vpn/evpn the default behaviour is nexthop-unchanged */ + if (afi == AFI_L2VPN && safi == SAFI_EVPN) + peer_af_flag_set(peer, afi, safi, PEER_FLAG_NEXTHOP_UNCHANGED); + return 0; } @@ -4072,6 +4080,32 @@ static int peer_af_flag_modify(struct peer *peer, afi_t afi, safi_t safi, return 0; } + /* + * For EVPN we implicitly set the NEXTHOP_UNCHANGED flag, + * if we are setting/unsetting flags which conflict with this flag + * handle accordingly + */ + if (afi == AFI_L2VPN && safi == SAFI_EVPN) { + if (set) { + + /* if we are setting NEXTHOP_SELF, we need to unset the + * NEXTHOP_UNCHANGED flag */ + if (CHECK_FLAG(flag, PEER_FLAG_NEXTHOP_SELF) || + CHECK_FLAG(flag, PEER_FLAG_FORCE_NEXTHOP_SELF)) + UNSET_FLAG(peer->af_flags[afi][safi], + PEER_FLAG_NEXTHOP_UNCHANGED); + } else { + + /* if we are unsetting NEXTHOP_SELF, we need to set the + * NEXTHOP_UNCHANGED flag to reset the defaults for EVPN + */ + if (CHECK_FLAG(flag, PEER_FLAG_NEXTHOP_SELF) || + CHECK_FLAG(flag, PEER_FLAG_FORCE_NEXTHOP_SELF)) + SET_FLAG(peer->af_flags[afi][safi], + PEER_FLAG_NEXTHOP_UNCHANGED); + } + } + if (set) SET_FLAG(peer->af_flags[afi][safi], flag); else @@ -7109,7 +7143,8 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, /* atribute-unchanged. */ if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) - || peer_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_UNCHANGED) + || (safi != SAFI_EVPN && + peer_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_UNCHANGED)) || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { if (!peer_group_active(peer) From 2017b3ead0406d721c2e89345831f90e172fa4c4 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 27 Apr 2018 09:21:28 -0400 Subject: [PATCH 14/24] zebra: Use STREAM_GETXXX functions Signed-off-by: Donald Sharp --- zebra/zebra_vxlan.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index efc3e8177a..a71cb24011 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -5158,7 +5158,7 @@ void zebra_vxlan_remote_macip_add(ZAPI_HANDLER_ARGS) l += IPV4_MAX_BYTELEN; /* Get flags - sticky mac and/or gateway mac */ - flags = stream_getc(s); + STREAM_GETC(s, flags); sticky = CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY); l++; @@ -6623,7 +6623,7 @@ void zebra_vxlan_advertise_subnet(ZAPI_HANDLER_ARGS) } s = msg; - advertise = stream_getc(s); + STREAM_GETC(s, advertise); vni = stream_get3(s); zvni = zvni_lookup(vni); @@ -6662,6 +6662,9 @@ void zebra_vxlan_advertise_subnet(ZAPI_HANDLER_ARGS) zvni_advertise_subnet(zvni, vlan_if, 1); else zvni_advertise_subnet(zvni, vlan_if, 0); + +stream_failure: + return; } /* From 637315fc78ce2a8bf64d725cffc72f29b266b325 Mon Sep 17 00:00:00 2001 From: Mitesh Kanjariya Date: Wed, 4 Apr 2018 13:01:45 -0700 Subject: [PATCH 15/24] bgpd: set NEXTHOP_UNCHANGED for l2vpn evpn by default for all BGP peers This flag needs to be set by default for l2vpn evpn address-family. We needed to find a place in the code which gets called by all peers at somepoint in the statemachine and before the routes are advertised. peer_new seems like the right place for this as we are setting other default af_flags here as well. Signed-off-by: Mitesh Kanjariya --- bgpd/bgpd.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index c6ad57f84a..36aa6b3c17 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -711,10 +711,6 @@ struct peer_af *peer_af_create(struct peer *peer, afi_t afi, safi_t safi) af->afid = afid; af->peer = peer; - /* for l2vpn/evpn the default behaviour is nexthop-unchanged */ - if (afi == AFI_L2VPN && safi == SAFI_EVPN) - peer_af_flag_set(peer, afi, safi, PEER_FLAG_NEXTHOP_UNCHANGED); - return af; } @@ -1178,6 +1174,11 @@ struct peer *peer_new(struct bgp *bgp) } peer->orf_plist[afi][safi] = NULL; } + + /* set nexthop-unchanged for l2vpn evpn by default */ + SET_FLAG(peer->af_flags[AFI_L2VPN][SAFI_EVPN], + PEER_FLAG_NEXTHOP_UNCHANGED); + SET_FLAG(peer->sflags, PEER_STATUS_CAPABILITY_OPEN); /* Create buffers. */ @@ -1932,10 +1933,6 @@ static int peer_activate_af(struct peer *peer, afi_t afi, safi_t safi) } } - /* for l2vpn/evpn the default behaviour is nexthop-unchanged */ - if (afi == AFI_L2VPN && safi == SAFI_EVPN) - peer_af_flag_set(peer, afi, safi, PEER_FLAG_NEXTHOP_UNCHANGED); - return 0; } From 1e00627b3bbb07f6d923461b6ac143a27e777f7e Mon Sep 17 00:00:00 2001 From: vivek Date: Fri, 13 Oct 2017 15:46:23 -0700 Subject: [PATCH 16/24] bgpd: Don't generate spurious warning on VNI deletion There are situations in which zebra may issue more than one delete notification, so BGP should not warn when it can't locate the VNI at delete. This is comparable to the situation when a withdraw is received but the route isn't present locally. Signed-off-by: Vivek Venkatraman Ticket: CM-17512 Reviewed By: Trivial Testing Done: Manual --- bgpd/bgp_evpn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 49808e7cdd..e3158e2b10 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -4421,8 +4421,9 @@ int bgp_evpn_local_vni_del(struct bgp *bgp, vni_t vni) /* Locate VNI hash */ vpn = bgp_evpn_lookup_vni(bgp, vni); if (!vpn) { - zlog_warn("%u: VNI hash entry for VNI %u not found at DEL", - bgp->vrf_id, vni); + if (bgp_debug_zebra(NULL)) + zlog_warn("%u: VNI hash entry for VNI %u not " + "found at DEL", bgp->vrf_id, vni); return 0; } From dcfe47166ad236aefc49bf0a0c262f500372d55b Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 24 Jan 2018 10:34:52 -0500 Subject: [PATCH 17/24] bgpd: Fix compiler warning->errors of might be used uninited Signed-off-by: Donald Sharp --- bgpd/bgp_evpn_vty.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 3fa2e38c00..fd3c229472 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -607,9 +607,9 @@ static void show_vni_routes_hash(struct hash_backet *backet, void *arg) static void show_l3vni_entry(struct vty *vty, struct bgp *bgp, json_object *json) { - json_object *json_vni; - json_object *json_import_rtl; - json_object *json_export_rtl; + json_object *json_vni = NULL; + json_object *json_import_rtl = NULL; + json_object *json_export_rtl = NULL; char buf1[10]; char buf2[INET6_ADDRSTRLEN]; char rt_buf[25]; From 8cb73ba40d85ca8f93aa7f976399e8151dea9c8e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 7 Jul 2017 13:42:40 -0400 Subject: [PATCH 18/24] zebra: Fixup crash with vlan interfaces attempted to be used When zebra starts up it receives from the kernel a full dump of interface information. Unfortunately it is in no particular order. As such we sometimes receive data from the kernel about interfaces we do not know about yet. In this bug, we are attempting to use the interface pointer(->link) for a vlan interface that we have not properly resolved. This fix ensures that we will not attempt to call zvni_map_svi if we have a NULL pointer. There are other places in the code we are already checking for the fact that the ->link pointer is valid before calling this function, so I believe that this is correct. We do need to come back and resolve all ->link pointers after we have received the full table. This can be done in another commit. Ticket: CM-17041 Signed-off-by: Donald Sharp --- zebra/interface.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/zebra/interface.c b/zebra/interface.c index 6f59a2d399..8d430be3e3 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1224,8 +1224,13 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp) br_slave->bridge_ifindex); } - if (zebra_if->link_ifindex != IFINDEX_INTERNAL) - vty_out(vty, " Link ifindex %u\n", zebra_if->link_ifindex); + if (zebra_if->link_ifindex != IFINDEX_INTERNAL) { + vty_out(vty, " Link ifindex %u", zebra_if->link_ifindex); + if (zebra_if->link) + vty_out(vty, "(%s)\n", zebra_if->link->name); + else + vty_out(vty, "(Unknown)\n"); + } if (HAS_LINK_PARAMS(ifp)) { int i; From 9ed7517b1a632dd3502107dce5ad8403604df462 Mon Sep 17 00:00:00 2001 From: vivek Date: Fri, 20 Apr 2018 08:40:42 -0700 Subject: [PATCH 19/24] zebra: Increase recvmsg buffer size for picking up netlink messages Netlink messages from the kernel need to be received in a buffer larger than 8K in order to handle some types of info - for example, the VLAN information. Define a separate size for receive and set it to 32K, which is the value used by other netlink receivers like iproute2. Signed-off-by: Vivek Venkatraman Reviewed-by: Donald Sharp --- zebra/kernel_netlink.c | 2 +- zebra/kernel_netlink.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c index db4f19460a..6b587dab38 100644 --- a/zebra/kernel_netlink.c +++ b/zebra/kernel_netlink.c @@ -463,7 +463,7 @@ int netlink_parse_info(int (*filter)(struct sockaddr_nl *, struct nlmsghdr *, int read_in = 0; while (1) { - char buf[NL_PKT_BUF_SIZE]; + char buf[NL_RCV_PKT_BUF_SIZE]; struct iovec iov = {.iov_base = buf, .iov_len = sizeof buf}; struct sockaddr_nl snl; struct msghdr msg = {.msg_name = (void *)&snl, diff --git a/zebra/kernel_netlink.h b/zebra/kernel_netlink.h index 8441eeac76..dc075b9aff 100644 --- a/zebra/kernel_netlink.h +++ b/zebra/kernel_netlink.h @@ -23,6 +23,7 @@ #ifdef HAVE_NETLINK +#define NL_RCV_PKT_BUF_SIZE 32768 #define NL_PKT_BUF_SIZE 8192 extern void netlink_parse_rtattr(struct rtattr **tb, int max, From 6c0a6053555440eda670c3fbc4238b45f625f4db Mon Sep 17 00:00:00 2001 From: vivek Date: Fri, 6 Apr 2018 09:31:11 -0700 Subject: [PATCH 20/24] bgpd: Fix VRF route leaking for multipath routes Ensure that the next hop of the leaked VRF is not overwritten when the route is being imported into the target VRF from the VPN table. Also, in the case of multipath routes, ensure that the nexthop's ifindex is not inadvertently reset. Signed-off-by: Vivek Venkatraman --- bgpd/bgp_zebra.c | 18 ++---------------- zebra/rt_netlink.c | 8 -------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index a86ea0e522..52a246387e 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1287,17 +1287,11 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, } } - if (bgp->table_map[afi][safi].name || nh_othervrf) { + if (bgp->table_map[afi][safi].name) { /* Copy info and attributes, so the route-map apply doesn't modify the BGP route info. */ local_attr = *mpinfo->attr; mpinfo_cp->attr = &local_attr; - if (nh_othervrf) { - /* allow route-map to modify */ - local_attr.nexthop = - info->extra->nexthop_orig.u - .prefix4; - } } if (bgp->table_map[afi][safi].name) { @@ -1322,19 +1316,11 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, ifindex_t ifindex; struct in6_addr *nexthop; - if (bgp->table_map[afi][safi].name || nh_othervrf) { + if (bgp->table_map[afi][safi].name) { /* Copy info and attributes, so the route-map apply doesn't modify the BGP route info. */ local_attr = *mpinfo->attr; mpinfo_cp->attr = &local_attr; - if (nh_othervrf) { - /* allow route-map to modify */ - local_attr.mp_nexthop_global = - info->extra->nexthop_orig.u - .prefix6; - local_attr.mp_nexthop_len = - BGP_ATTR_NHLEN_IPV6_GLOBAL; - } } if (bgp->table_map[afi][safi].name) { diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 1d43567ce3..9510a0e12c 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1233,14 +1233,6 @@ static void _netlink_route_build_multipath(const char *routedesc, int bytelen, "netlink_route_multipath() (%s): " "nexthop via if %u", routedesc, nexthop->ifindex); - } else if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) { - if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug( - "netlink_route_multipath() (%s): " - "nexthop via if %u", - routedesc, nexthop->ifindex); - } else { - rtnh->rtnh_ifindex = 0; } } From a2023fab273dd7cf34a3a9fed1361b7c25c65bb0 Mon Sep 17 00:00:00 2001 From: radhika Date: Tue, 1 Aug 2017 10:10:35 -0700 Subject: [PATCH 21/24] Zebra: Fix ptm-enable config failure on internally created interfaces Ticket: CM-15658 Reviewed By: CCR-6534 Testing Done: Unit Issue: frr ptm-enable command not working for interfaces that have been created by frr as a place holder. Root Cause: The ptm-enable on interface configuration was not getting stored when the interface was internally created by frr. Fix: Store the ptm-enable configuration even if the interface is internally created. Signed-off-by: Radhika Mahankali --- zebra/zebra_ptm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index 07e81aa020..d20f93f521 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -298,6 +298,9 @@ DEFUN (zebra_ptm_enable_if, int old_ptm_enable; int send_linkdown = 0; + if_data = ifp->info; + if_data->ptm_enable = ZEBRA_IF_PTM_ENABLE_UNSPEC; + if (ifp->ifindex == IFINDEX_INTERNAL) { return CMD_SUCCESS; } @@ -317,9 +320,6 @@ DEFUN (zebra_ptm_enable_if, } } - if_data = ifp->info; - if_data->ptm_enable = ZEBRA_IF_PTM_ENABLE_UNSPEC; - return CMD_SUCCESS; } From 3518f3526429afbcb5aaa3006e81cba83c3d598d Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 29 Apr 2018 14:35:39 -0400 Subject: [PATCH 22/24] bgpd, lib, zebra: Cleanup formatting issues found Cleanup the formating issues found. Signed-off-by: Donald Sharp --- bgpd/bgp_evpn.c | 5 +++-- bgpd/bgp_route.c | 14 ++++++-------- bgpd/bgpd.c | 14 +++++++++----- lib/command.c | 36 ++++++++++++++++++++++-------------- zebra/zebra_vxlan.c | 9 +++++---- 5 files changed, 45 insertions(+), 33 deletions(-) diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index e3158e2b10..e910e2ef64 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -4422,8 +4422,9 @@ int bgp_evpn_local_vni_del(struct bgp *bgp, vni_t vni) vpn = bgp_evpn_lookup_vni(bgp, vni); if (!vpn) { if (bgp_debug_zebra(NULL)) - zlog_warn("%u: VNI hash entry for VNI %u not " - "found at DEL", bgp->vrf_id, vni); + zlog_warn( + "%u: VNI hash entry for VNI %u not found at DEL", + bgp->vrf_id, vni); return 0; } diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 401a7e8549..1a19cfc1a9 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2369,15 +2369,13 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn, if (bgp->adv_cmd_rmap[afi][safi].map) { int ret = 0; - ret = - route_map_apply( - bgp->adv_cmd_rmap[afi][safi].map, - &rn->p, RMAP_BGP, new_select); + ret = route_map_apply( + bgp->adv_cmd_rmap[afi][safi].map, + &rn->p, RMAP_BGP, new_select); if (ret == RMAP_MATCH) - bgp_evpn_advertise_type5_route(bgp, - &rn->p, - new_select->attr, - afi, safi); + bgp_evpn_advertise_type5_route( + bgp, &rn->p, new_select->attr, + afi, safi); } else { bgp_evpn_advertise_type5_route(bgp, &rn->p, diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 36aa6b3c17..09a4fda7b2 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -4085,15 +4085,18 @@ static int peer_af_flag_modify(struct peer *peer, afi_t afi, safi_t safi, if (afi == AFI_L2VPN && safi == SAFI_EVPN) { if (set) { - /* if we are setting NEXTHOP_SELF, we need to unset the - * NEXTHOP_UNCHANGED flag */ + /* + * if we are setting NEXTHOP_SELF, we need to unset the + * NEXTHOP_UNCHANGED flag + */ if (CHECK_FLAG(flag, PEER_FLAG_NEXTHOP_SELF) || CHECK_FLAG(flag, PEER_FLAG_FORCE_NEXTHOP_SELF)) UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED); } else { - /* if we are unsetting NEXTHOP_SELF, we need to set the + /* + * if we are unsetting NEXTHOP_SELF, we need to set the * NEXTHOP_UNCHANGED flag to reset the defaults for EVPN */ if (CHECK_FLAG(flag, PEER_FLAG_NEXTHOP_SELF) || @@ -7140,8 +7143,9 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, /* atribute-unchanged. */ if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) - || (safi != SAFI_EVPN && - peer_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_UNCHANGED)) + || (safi != SAFI_EVPN + && peer_af_flag_check(peer, afi, safi, + PEER_FLAG_NEXTHOP_UNCHANGED)) || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { if (!peer_group_active(peer) diff --git a/lib/command.c b/lib/command.c index d0417408b2..fb558b64d3 100644 --- a/lib/command.c +++ b/lib/command.c @@ -530,15 +530,16 @@ static int config_write_host(struct vty *vty) vty_out(vty, "domainname %s\n", cmd_domainname_get()); /* The following are all configuration commands that are not sent to - * watchfrr. For instance watchfrr is hardcoded to log to syslog so - * we would always display 'log syslog informational' in the config - * which would cause other daemons to then switch to syslog when they - * parse frr.conf. - */ + * watchfrr. For instance watchfrr is hardcoded to log to syslog so + * we would always display 'log syslog informational' in the config + * which would cause other daemons to then switch to syslog when they + * parse frr.conf. + */ if (strcmp(zlog_default->protoname, "WATCHFRR")) { if (host.encrypt) { if (host.password_encrypt) - vty_out(vty, "password 8 %s\n", host.password_encrypt); + vty_out(vty, "password 8 %s\n", + host.password_encrypt); if (host.enable_encrypt) vty_out(vty, "enable password 8 %s\n", host.enable_encrypt); @@ -546,23 +547,27 @@ static int config_write_host(struct vty *vty) if (host.password) vty_out(vty, "password %s\n", host.password); if (host.enable) - vty_out(vty, "enable password %s\n", host.enable); + vty_out(vty, "enable password %s\n", + host.enable); } if (zlog_default->default_lvl != LOG_DEBUG) { - vty_out(vty, "! N.B. The 'log trap' command is deprecated.\n"); + vty_out(vty, + "! N.B. The 'log trap' command is deprecated.\n"); vty_out(vty, "log trap %s\n", zlog_priority[zlog_default->default_lvl]); } if (host.logfile - && (zlog_default->maxlvl[ZLOG_DEST_FILE] != ZLOG_DISABLED)) { + && (zlog_default->maxlvl[ZLOG_DEST_FILE] + != ZLOG_DISABLED)) { vty_out(vty, "log file %s", host.logfile); if (zlog_default->maxlvl[ZLOG_DEST_FILE] != zlog_default->default_lvl) vty_out(vty, " %s", zlog_priority - [zlog_default->maxlvl[ZLOG_DEST_FILE]]); + [zlog_default->maxlvl + [ZLOG_DEST_FILE]]); vty_out(vty, "\n"); } @@ -571,8 +576,9 @@ static int config_write_host(struct vty *vty) if (zlog_default->maxlvl[ZLOG_DEST_STDOUT] != zlog_default->default_lvl) vty_out(vty, " %s", - zlog_priority[zlog_default->maxlvl - [ZLOG_DEST_STDOUT]]); + zlog_priority + [zlog_default->maxlvl + [ZLOG_DEST_STDOUT]]); vty_out(vty, "\n"); } @@ -581,7 +587,8 @@ static int config_write_host(struct vty *vty) else if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] != zlog_default->default_lvl) vty_out(vty, "log monitor %s\n", - zlog_priority[zlog_default->maxlvl[ZLOG_DEST_MONITOR]]); + zlog_priority[zlog_default->maxlvl + [ZLOG_DEST_MONITOR]]); if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] != ZLOG_DISABLED) { vty_out(vty, "log syslog"); @@ -611,7 +618,8 @@ static int config_write_host(struct vty *vty) vty_out(vty, "service password-encryption\n"); if (host.lines >= 0) - vty_out(vty, "service terminal-length %d\n", host.lines); + vty_out(vty, "service terminal-length %d\n", + host.lines); if (host.motdfile) vty_out(vty, "banner motd file %s\n", host.motdfile); diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index a71cb24011..3278c86b99 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -3949,11 +3949,11 @@ void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id, struct ethaddr *rmac, if (!zl3vni || !is_l3vni_oper_up(zl3vni)) return; - /* + /* * add the next hop neighbor - * neigh to be installed is the ipv6 nexthop neigh */ - zl3vni_remote_nh_add(zl3vni, vtep_ip, rmac, host_prefix); + zl3vni_remote_nh_add(zl3vni, vtep_ip, rmac, host_prefix); /* * if the remote vtep is a ipv4 mapped ipv6 address convert it to ipv4 @@ -3969,10 +3969,11 @@ void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id, struct ethaddr *rmac, memcpy(&(ipv4_vtep.ipaddr_v4), &vtep_ip->ipaddr_v4, sizeof(struct in_addr)); - /* add the rmac - remote rmac to be installed is against the ipv4 + /* + * add the rmac - remote rmac to be installed is against the ipv4 * nexthop address */ - zl3vni_remote_rmac_add(zl3vni, rmac, &ipv4_vtep, host_prefix); + zl3vni_remote_rmac_add(zl3vni, rmac, &ipv4_vtep, host_prefix); } /* handle evpn vrf route delete */ From e543616348f18fbc08931fc19a71e78d843ab6fb Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 8 May 2018 19:31:40 -0400 Subject: [PATCH 23/24] doc: Fix pbr documentation to be correct The recent change of pbr necessitates this change in the doc Signed-off-by: Donald Sharp --- doc/user/pbr.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/user/pbr.rst b/doc/user/pbr.rst index eec575cf3f..aa48a3cd4f 100644 --- a/doc/user/pbr.rst +++ b/doc/user/pbr.rst @@ -57,7 +57,7 @@ against incoming packets. If matched the nexthop-group or nexthop is used to forward the packets to the end destination .. index:: pbr-map -.. clicmd:: pbr-map NAME seq (1-1000) +.. clicmd:: pbr-map NAME seq (1-700) Create a pbr-map with NAME and sequence number specified. This command puts you into a new submode for pbr-map specification. To exit this mode type From 914432b5ebaf682fae7647c595fa74657fe32833 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 8 May 2018 19:33:07 -0400 Subject: [PATCH 24/24] lib: Fix bad function Fix the decleration of a function to be better. Signed-off-by: Donald Sharp --- lib/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/command.c b/lib/command.c index fb558b64d3..d90e33e42a 100644 --- a/lib/command.c +++ b/lib/command.c @@ -2346,7 +2346,7 @@ DEFUN (config_log_file, zlog_default->default_lvl); } -static void disable_log_file() +static void disable_log_file(void) { zlog_reset_file();