diff options
author | Hiroki Shirokura <slank.dev@gmail.com> | 2021-04-23 14:46:07 +0200 |
---|---|---|
committer | Mark Stapp <mjs@voltanet.io> | 2021-06-02 16:24:48 +0200 |
commit | c60c1ade86c1c999f5219c0ebc35374acddb661c (patch) | |
tree | c6ce5abfb04ada0bd371990760691779d925d95b | |
parent | zebra: early return on seg6local nlmsg crafting (diff) | |
download | frr-c60c1ade86c1c999f5219c0ebc35374acddb661c.tar.xz frr-c60c1ade86c1c999f5219c0ebc35374acddb661c.zip |
*: delete ZEBRA_FLAG_SEG6*_ROUTE and add ZAPI_NEXTHOP_FLAG_SEG6*
https://github.com/FRRouting/frr/pull/5865#discussion_r597670225
As this comment says. ZEBRA_FLAG_XXX should not have been used.
To communicate SRv6 Route Information. A simple Nexthop Flag would
have been sufficient for SRv6 information. And I fixed the whole
thing that way.
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
-rw-r--r-- | bgpd/bgp_zebra.c | 2 | ||||
-rw-r--r-- | lib/zclient.c | 15 | ||||
-rw-r--r-- | lib/zclient.h | 12 | ||||
-rw-r--r-- | sharpd/sharp_vty.c | 3 | ||||
-rw-r--r-- | tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r1/vrf10_rib.json | 2 | ||||
-rw-r--r-- | tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r1/vrf20_rib.json | 4 | ||||
-rw-r--r-- | tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r2/vrf10_rib.json | 4 | ||||
-rw-r--r-- | tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r2/vrf20_rib.json | 2 | ||||
-rw-r--r-- | zebra/zapi_msg.c | 4 |
9 files changed, 20 insertions, 28 deletions
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index d4a4ed230..e3a795c6f 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1408,7 +1408,7 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p, } if (has_valid_sid && !(CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE))) - SET_FLAG(api.flags, ZEBRA_FLAG_SEG6_ROUTE); + SET_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_SEG6); is_add = (valid_nh_count || nhg_id) ? true : false; diff --git a/lib/zclient.c b/lib/zclient.c index 4eef55e46..10dda5ba0 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -459,11 +459,11 @@ enum zclient_send_status zclient_send_localsid(struct zclient *zclient, return zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); SET_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION); - SET_FLAG(api.flags, ZEBRA_FLAG_SEG6LOCAL_ROUTE); SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); nh.type = NEXTHOP_TYPE_IFINDEX; nh.ifindex = oif; + SET_FLAG(nh.flags, ZAPI_NEXTHOP_FLAG_SEG6LOCAL); nexthop_add_srv6_seg6local(&nh, action, context); zapi_nexthop_from_nexthop(&api.nexthops[0], &nh); @@ -1053,13 +1053,13 @@ int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh, stream_putc(s, api_nh->backup_idx[i]); } - if (CHECK_FLAG(api_flags, ZEBRA_FLAG_SEG6LOCAL_ROUTE)) { + if (CHECK_FLAG(nh_flags, ZAPI_NEXTHOP_FLAG_SEG6LOCAL)) { stream_putl(s, api_nh->seg6local_action); stream_write(s, &api_nh->seg6local_ctx, sizeof(struct seg6local_context)); } - if (CHECK_FLAG(api_flags, ZEBRA_FLAG_SEG6_ROUTE)) + if (CHECK_FLAG(nh_flags, ZAPI_NEXTHOP_FLAG_SEG6)) stream_write(s, &api_nh->seg6_segs, sizeof(struct in6_addr)); @@ -1382,13 +1382,13 @@ int zapi_nexthop_decode(struct stream *s, struct zapi_nexthop *api_nh, STREAM_GETC(s, api_nh->backup_idx[i]); } - if (CHECK_FLAG(api_flags, ZEBRA_FLAG_SEG6LOCAL_ROUTE)) { + if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_SEG6LOCAL)) { STREAM_GETL(s, api_nh->seg6local_action); STREAM_GET(&api_nh->seg6local_ctx, s, sizeof(struct seg6local_context)); } - if (CHECK_FLAG(api_flags, ZEBRA_FLAG_SEG6_ROUTE)) + if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_SEG6)) STREAM_GET(&api_nh->seg6_segs, s, sizeof(struct in6_addr)); @@ -1810,15 +1810,18 @@ int zapi_nexthop_from_nexthop(struct zapi_nexthop *znh, if (nh->nh_srv6) { if (nh->nh_srv6->seg6local_action != ZEBRA_SEG6_LOCAL_ACTION_UNSPEC) { + SET_FLAG(znh->flags, ZAPI_NEXTHOP_FLAG_SEG6LOCAL); znh->seg6local_action = nh->nh_srv6->seg6local_action; memcpy(&znh->seg6local_ctx, &nh->nh_srv6->seg6local_ctx, sizeof(struct seg6local_context)); } - if (!sid_zero(&nh->nh_srv6->seg6_segs)) + if (!sid_zero(&nh->nh_srv6->seg6_segs)) { + SET_FLAG(znh->flags, ZAPI_NEXTHOP_FLAG_SEG6); memcpy(&znh->seg6_segs, &nh->nh_srv6->seg6_segs, sizeof(struct in6_addr)); + } } return 0; diff --git a/lib/zclient.h b/lib/zclient.h index c41d25133..48de3425b 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -488,6 +488,8 @@ struct zapi_nexthop { #define ZAPI_NEXTHOP_FLAG_LABEL 0x02 #define ZAPI_NEXTHOP_FLAG_WEIGHT 0x04 #define ZAPI_NEXTHOP_FLAG_HAS_BACKUP 0x08 /* Nexthop has a backup */ +#define ZAPI_NEXTHOP_FLAG_SEG6 0x10 +#define ZAPI_NEXTHOP_FLAG_SEG6LOCAL 0x20 /* * ZAPI Nexthop Group. For use with protocol creation of nexthop groups. @@ -572,16 +574,6 @@ struct zapi_route { * offload situation. */ #define ZEBRA_FLAG_OFFLOAD_FAILED 0x200 -/* - * This flag tells Zebra that the route is a seg6 route and should - * be treated specially. - */ -#define ZEBRA_FLAG_SEG6_ROUTE 0x400 -/* - * This flag tells Zebra that the route is a seg6local route and - * should be treated specially. - */ -#define ZEBRA_FLAG_SEG6LOCAL_ROUTE 0x800 /* The older XXX_MESSAGE flags live here */ uint32_t message; diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 7482a6da6..1a3c5f450 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -406,9 +406,7 @@ DEFPY (install_seg6_routes, sg.r.nhop.gate.ipv6 = seg6_nh6; sg.r.nhop.vrf_id = vrf->vrf_id; sg.r.nhop_group.nexthop = &sg.r.nhop; - nexthop_add_srv6_seg6(&sg.r.nhop, &seg6_seg); - SET_FLAG(route_flags, ZEBRA_FLAG_SEG6_ROUTE); sg.r.vrf_id = vrf->vrf_id; sharp_install_routes_helper(&prefix, sg.r.vrf_id, sg.r.inst, 0, @@ -505,7 +503,6 @@ DEFPY (install_seg6local_routes, sg.r.nhop.vrf_id = vrf->vrf_id; sg.r.nhop_group.nexthop = &sg.r.nhop; nexthop_add_srv6_seg6local(&sg.r.nhop, action, &ctx); - SET_FLAG(route_flags, ZEBRA_FLAG_SEG6LOCAL_ROUTE); sg.r.vrf_id = vrf->vrf_id; sharp_install_routes_helper(&sg.r.orig_prefix, sg.r.vrf_id, sg.r.inst, 0, diff --git a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r1/vrf10_rib.json b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r1/vrf10_rib.json index 9219d9ad3..fa05972a3 100644 --- a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r1/vrf10_rib.json +++ b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r1/vrf10_rib.json @@ -37,7 +37,7 @@ "installed": true, "table": 10, "internalStatus": 16, - "internalFlags": 1032, + "internalFlags": 8, "internalNextHopNum": 1, "internalNextHopActiveNum": 1, "nexthops": [ diff --git a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r1/vrf20_rib.json b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r1/vrf20_rib.json index cd4c7d503..015555724 100644 --- a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r1/vrf20_rib.json +++ b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r1/vrf20_rib.json @@ -11,7 +11,7 @@ "installed": true, "table": 20, "internalStatus": 16, - "internalFlags": 1032, + "internalFlags": 8, "internalNextHopNum": 1, "internalNextHopActiveNum": 1, "nexthops": [ @@ -72,7 +72,7 @@ "installed": true, "table": 20, "internalStatus": 16, - "internalFlags": 1032, + "internalFlags": 8, "internalNextHopNum": 1, "internalNextHopActiveNum": 1, "nexthops": [ diff --git a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r2/vrf10_rib.json b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r2/vrf10_rib.json index 5ae377c39..887eb2438 100644 --- a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r2/vrf10_rib.json +++ b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r2/vrf10_rib.json @@ -11,7 +11,7 @@ "installed": true, "table": 10, "internalStatus": 16, - "internalFlags": 1032, + "internalFlags": 8, "internalNextHopNum": 1, "internalNextHopActiveNum": 1, "nexthops": [ @@ -72,7 +72,7 @@ "installed": true, "table": 10, "internalStatus": 16, - "internalFlags": 1032, + "internalFlags": 8, "internalNextHopNum": 1, "internalNextHopActiveNum": 1, "nexthops": [ diff --git a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r2/vrf20_rib.json b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r2/vrf20_rib.json index ea1fe4c2a..c11851842 100644 --- a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r2/vrf20_rib.json +++ b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/r2/vrf20_rib.json @@ -37,7 +37,7 @@ "installed": true, "table": 20, "internalStatus": 16, - "internalFlags": 1032, + "internalFlags": 8, "internalNextHopNum": 1, "internalNextHopActiveNum": 1, "nexthops": [ diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index f6151463c..06aaa706d 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1748,7 +1748,7 @@ static bool zapi_read_nexthops(struct zserv *client, struct prefix *p, &api_nh->labels[0]); } - if (CHECK_FLAG(flags, ZEBRA_FLAG_SEG6LOCAL_ROUTE) + if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_SEG6LOCAL) && api_nh->type != NEXTHOP_TYPE_BLACKHOLE) { if (IS_ZEBRA_DEBUG_RECV) zlog_debug("%s: adding seg6local action %s", @@ -1761,7 +1761,7 @@ static bool zapi_read_nexthops(struct zserv *client, struct prefix *p, &api_nh->seg6local_ctx); } - if (CHECK_FLAG(flags, ZEBRA_FLAG_SEG6_ROUTE) + if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_SEG6) && api_nh->type != NEXTHOP_TYPE_BLACKHOLE) { if (IS_ZEBRA_DEBUG_RECV) zlog_debug("%s: adding seg6", __func__); |