diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/command.h | 2 | ||||
| -rw-r--r-- | lib/command_match.c | 6 | ||||
| -rw-r--r-- | lib/grammar_sandbox.c | 18 | ||||
| -rw-r--r-- | lib/log.c | 2 | ||||
| -rw-r--r-- | lib/nexthop.h | 1 | ||||
| -rw-r--r-- | lib/prefix.c | 5 | ||||
| -rw-r--r-- | lib/prefix.h | 10 | ||||
| -rw-r--r-- | lib/vrf.c | 11 | ||||
| -rw-r--r-- | lib/vrf.h | 1 | ||||
| -rw-r--r-- | lib/zclient.c | 14 | ||||
| -rw-r--r-- | lib/zclient.h | 6 | ||||
| -rw-r--r-- | lib/zebra.h | 1 |
12 files changed, 60 insertions, 17 deletions
diff --git a/lib/command.h b/lib/command.h index 42dd1c5325..fa8323bf2d 100644 --- a/lib/command.h +++ b/lib/command.h @@ -190,7 +190,7 @@ struct cmd_node { #define CMD_NOT_MY_INSTANCE 14 /* Argc max counts. */ -#define CMD_ARGC_MAX 25 +#define CMD_ARGC_MAX 256 /* Turn off these macros when uisng cpp with extract.pl */ #ifndef VTYSH_EXTRACT_PL diff --git a/lib/command_match.c b/lib/command_match.c index c60373f910..f6b07a0b20 100644 --- a/lib/command_match.c +++ b/lib/command_match.c @@ -28,8 +28,6 @@ DEFINE_MTYPE_STATIC(LIB, CMD_MATCHSTACK, "Command Match Stack") -#define MAXDEPTH 256 - #ifdef TRACE_MATCHER #define TM 1 #else @@ -84,7 +82,7 @@ static enum match_type match_mac(const char *, bool); enum matcher_rv command_match(struct graph *cmdgraph, vector vline, struct list **argv, const struct cmd_element **el) { - struct graph_node *stack[MAXDEPTH]; + struct graph_node *stack[CMD_ARGC_MAX]; enum matcher_rv status; *argv = NULL; @@ -200,7 +198,7 @@ static enum matcher_rv command_match_r(struct graph_node *start, vector vline, /* check history/stack of tokens * this disallows matching the same one more than once if there is a * circle in the graph (used for keyword arguments) */ - if (n == MAXDEPTH) + if (n == CMD_ARGC_MAX) return MATCHER_NO_MATCH; if (!token->allowrepeat) for (size_t s = 0; s < n; s++) diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c index 66b042ad97..79c951dd69 100644 --- a/lib/grammar_sandbox.c +++ b/lib/grammar_sandbox.c @@ -33,8 +33,6 @@ DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command desc") -#define MAXDEPTH 64 - /** headers **/ void grammar_sandbox_init(void); void pretty_print_graph(struct vty *vty, struct graph_node *, int, int, @@ -262,7 +260,7 @@ DEFUN (grammar_test_show, { check_nodegraph(); - struct graph_node *stack[MAXDEPTH]; + struct graph_node *stack[CMD_ARGC_MAX]; pretty_print_graph(vty, vector_slot(nodegraph->nodes, 0), 0, argc >= 3, stack, 0); return CMD_SUCCESS; @@ -277,8 +275,8 @@ DEFUN (grammar_test_dot, { check_nodegraph(); - struct graph_node *stack[MAXDEPTH]; - struct graph_node *visited[MAXDEPTH * MAXDEPTH]; + struct graph_node *stack[CMD_ARGC_MAX]; + struct graph_node *visited[CMD_ARGC_MAX * CMD_ARGC_MAX]; size_t vpos = 0; FILE *ofd = fopen(argv[2]->arg, "w"); @@ -334,7 +332,7 @@ static void cmd_graph_permute(struct list *out, struct graph_node **stack, return; } - if (++stackpos == MAXDEPTH) + if (++stackpos == CMD_ARGC_MAX) return; for (i = 0; i < vector_active(gn->to); i++) { @@ -354,7 +352,7 @@ static void cmd_graph_permute(struct list *out, struct graph_node **stack, static struct list *cmd_graph_permutations(struct graph *graph) { char accumulate[2048] = ""; - struct graph_node *stack[MAXDEPTH]; + struct graph_node *stack[CMD_ARGC_MAX]; struct list *rv = list_new(); rv->cmp = cmd_permute_cmp; @@ -532,7 +530,7 @@ void pretty_print_graph(struct vty *vty, struct graph_node *start, int level, vty_out(vty, " ?'%s'", tok->desc); vty_out(vty, " "); - if (stackpos == MAXDEPTH) { + if (stackpos == CMD_ARGC_MAX) { vty_out(vty, " -aborting! (depth limit)\n"); return; } @@ -586,7 +584,7 @@ static void pretty_print_dot(FILE *ofd, unsigned opts, struct graph_node *start, if (visited[i] == start) return; visited[(*visitpos)++] = start; - if ((*visitpos) == MAXDEPTH * MAXDEPTH) + if ((*visitpos) == CMD_ARGC_MAX * CMD_ARGC_MAX) return; snprintf(tokennum, sizeof(tokennum), "%d?", tok->type); @@ -626,7 +624,7 @@ static void pretty_print_dot(FILE *ofd, unsigned opts, struct graph_node *start, } fprintf(ofd, ">, style = filled, fillcolor = \"%s\" ];\n", color); - if (stackpos == MAXDEPTH) + if (stackpos == CMD_ARGC_MAX) return; stack[stackpos++] = start; @@ -945,6 +945,8 @@ static const struct zebra_desc_table command_types[] = { DESC_ENTRY(ZEBRA_ADVERTISE_DEFAULT_GW), DESC_ENTRY(ZEBRA_VNI_ADD), DESC_ENTRY(ZEBRA_VNI_DEL), + DESC_ENTRY(ZEBRA_L3VNI_ADD), + DESC_ENTRY(ZEBRA_L3VNI_DEL), DESC_ENTRY(ZEBRA_REMOTE_VTEP_ADD), DESC_ENTRY(ZEBRA_REMOTE_VTEP_DEL), DESC_ENTRY(ZEBRA_MACIP_ADD), diff --git a/lib/nexthop.h b/lib/nexthop.h index 20b0cd5227..a727f37057 100644 --- a/lib/nexthop.h +++ b/lib/nexthop.h @@ -80,6 +80,7 @@ struct nexthop { #define NEXTHOP_FLAG_MATCHED (1 << 4) /* Already matched vs a nexthop */ #define NEXTHOP_FLAG_FILTERED (1 << 5) /* rmap filtered, used by static only */ #define NEXTHOP_FLAG_DUPLICATE (1 << 6) /* nexthop duplicates another active one */ +#define NEXTHOP_FLAG_EVPN_RVTEP (1 << 7) /* EVPN remote vtep nexthop */ #define NEXTHOP_IS_ACTIVE(flags) \ (CHECK_FLAG(flags, NEXTHOP_FLAG_ACTIVE) \ && !CHECK_FLAG(flags, NEXTHOP_FLAG_DUPLICATE)) diff --git a/lib/prefix.c b/lib/prefix.c index 10f77bda87..9f13cb8bb1 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -301,7 +301,7 @@ static const struct in6_addr maskbytes6[] = { #define MASKBIT(offset) ((0xff << (PNBBY - (offset))) & 0xff) -static int is_zero_mac(const struct ethaddr *mac) +int is_zero_mac(struct ethaddr *mac) { int i = 0; @@ -1043,10 +1043,11 @@ static const char *prefixevpn2str(const struct prefix *p, char *str, int size) family = IS_EVPN_PREFIX_IPADDR_V4((struct prefix_evpn *)p) ? AF_INET : AF_INET6; - snprintf(str, size, "[%d]:[%u][%s]/%d", + snprintf(str, size, "[%d]:[%u][%s/%d]/%d", p->u.prefix_evpn.route_type, p->u.prefix_evpn.eth_tag, inet_ntop(family, &p->u.prefix_evpn.ip.ip.addr, buf, PREFIX2STR_BUFFER), + p->u.prefix_evpn.ip_prefix_length, p->prefixlen); } else { sprintf(str, "Unsupported EVPN route type %d", diff --git a/lib/prefix.h b/lib/prefix.h index 0732cf1290..7e947ea48a 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -348,6 +348,7 @@ extern void masklen2ip6(const int, struct in6_addr *); extern const char *inet6_ntoa(struct in6_addr); +extern int is_zero_mac(struct ethaddr *mac); extern int prefix_str2mac(const char *str, struct ethaddr *mac); extern char *prefix_mac2str(const struct ethaddr *mac, char *buf, int size); @@ -398,4 +399,13 @@ static inline int is_default_prefix(const struct prefix *p) return 0; } +static inline int is_host_route(struct prefix *p) +{ + if (p->family == AF_INET) + return (p->prefixlen == IPV4_MAX_BITLEN); + else if (p->family == AF_INET6) + return (p->prefixlen == IPV6_MAX_BITLEN); + return 0; +} + #endif /* _ZEBRA_PREFIX_H */ @@ -225,6 +225,17 @@ static void vrf_disable(struct vrf *vrf) (*vrf_master.vrf_disable_hook)(vrf); } +const char *vrf_id_to_name(vrf_id_t vrf_id) +{ + struct vrf *vrf; + + vrf = vrf_lookup_by_id(vrf_id); + if (vrf) + return vrf->name; + + return "n/a"; +} + vrf_id_t vrf_name_to_id(const char *name) { struct vrf *vrf; @@ -103,6 +103,7 @@ extern struct vrf_name_head vrfs_by_name; extern struct vrf *vrf_lookup_by_id(vrf_id_t); extern struct vrf *vrf_lookup_by_name(const char *); extern struct vrf *vrf_get(vrf_id_t, const char *); +extern const char *vrf_id_to_name(vrf_id_t vrf_id); extern vrf_id_t vrf_name_to_id(const char *); #define VRF_GET_ID(V, NAME) \ diff --git a/lib/zclient.c b/lib/zclient.c index 655e4e1a80..4177ce1a71 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -912,6 +912,8 @@ int zapi_route_encode(u_char 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); @@ -1032,6 +1034,8 @@ 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); @@ -2205,6 +2209,16 @@ static int zclient_read(struct thread *thread) (*zclient->local_vni_del)(command, zclient, length, vrf_id); break; + case ZEBRA_L3VNI_ADD: + if (zclient->local_l3vni_add) + (*zclient->local_l3vni_add)(command, zclient, length, + vrf_id); + break; + case ZEBRA_L3VNI_DEL: + if (zclient->local_l3vni_del) + (*zclient->local_l3vni_del)(command, zclient, length, + vrf_id); + break; case ZEBRA_MACIP_ADD: if (zclient->local_macip_add) (*zclient->local_macip_add)(command, zclient, length, diff --git a/lib/zclient.h b/lib/zclient.h index de58044671..cc34fd9d2c 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -112,6 +112,8 @@ typedef enum { ZEBRA_ADVERTISE_ALL_VNI, ZEBRA_VNI_ADD, ZEBRA_VNI_DEL, + ZEBRA_L3VNI_ADD, + ZEBRA_L3VNI_DEL, ZEBRA_REMOTE_VTEP_ADD, ZEBRA_REMOTE_VTEP_DEL, ZEBRA_MACIP_ADD, @@ -200,6 +202,8 @@ struct zclient { int (*fec_update)(int, struct zclient *, uint16_t); int (*local_vni_add)(int, struct zclient *, uint16_t, vrf_id_t); int (*local_vni_del)(int, struct zclient *, uint16_t, vrf_id_t); + int (*local_l3vni_add)(int, struct zclient *, uint16_t, vrf_id_t); + int (*local_l3vni_del)(int, struct zclient *, uint16_t, vrf_id_t); int (*local_macip_add)(int, struct zclient *, uint16_t, vrf_id_t); int (*local_macip_del)(int, struct zclient *, uint16_t, vrf_id_t); int (*pw_status_update)(int, struct zclient *, uint16_t, vrf_id_t); @@ -277,6 +281,8 @@ struct zapi_route { u_int32_t mtu; vrf_id_t vrf_id; + + struct ethaddr rmac; }; /* Zebra IPv4 route message API. */ diff --git a/lib/zebra.h b/lib/zebra.h index fa5fa89f77..1eb0c56252 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -409,6 +409,7 @@ extern const char *zserv_command_string(unsigned int command); #define ZEBRA_FLAG_STATIC 0x40 #define ZEBRA_FLAG_SCOPE_LINK 0x100 #define ZEBRA_FLAG_FIB_OVERRIDE 0x200 +#define ZEBRA_FLAG_EVPN_ROUTE 0x400 /* ZEBRA_FLAG_BLACKHOLE was 0x04 */ /* ZEBRA_FLAG_REJECT was 0x80 */ |
