]> git.puffer.fish Git - matthieu/frr.git/commitdiff
shaprd: install route supports nexthop-seg6local (step1)
authorHiroki Shirokura <slank.dev@gmail.com>
Sun, 6 Dec 2020 00:10:33 +0000 (09:10 +0900)
committerMark Stapp <mjs@voltanet.io>
Wed, 2 Jun 2021 14:24:47 +0000 (10:24 -0400)
In this patch, we can install seg6local routes from shapd cli. New sub
command "sharp install route $PREFIX nexthop-seg6local" is added to
install seg6local routes via ZEBRA_ROUTE_ADD. This is for the behaviour
test(topotest) to ensure SRv6 ZAPI is working fine.

NEW-CLI:
sharp install routes 1::1 nexthop-seg6local dum0 End 1
sharp install routes 2::1 nexthop-seg6local dum0 End_X 2001::1 1
sharp install routes 3::1 nexthop-seg6local dum0 End_T 10 1
sharp install routes 4::1 nexthop-seg6local dum0 End_DX4 10.0.0.1 1

SRv6 routes are installed as NEXTHOP_IFINDEX routes because of seg6local
specification. seg6local routes depends the output device status instead
of routing-nexthop.

FYI:
In seg6local implementation, kernel don't care RTA_OIF on the nexthop
deeply but some requirement are exist as follow.
(a) DEV isn't loopback interface
(b) DEV's ipv6 status is enabled
(c) DEV's enslaving status is the same with target-route

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
sharpd/sharp_vty.c

index de2d092c36c2758c075c4598784e7f8b1470d204..253d1943b338a4ef79d7e5826e2e876b2f1aabcf 100644 (file)
@@ -189,7 +189,13 @@ DEFPY (install_routes,
        "sharp install routes [vrf NAME$vrf_name]\
          <A.B.C.D$start4|X:X::X:X$start6>\
          <nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6>|\
-          nexthop-group NHGNAME$nexthop_group>\
+          nexthop-group NHGNAME$nexthop_group|\
+          nexthop-seg6local NAME$seg6l_oif\
+            <End$seg6l_end|\
+             End_X$seg6l_endx X:X::X:X$seg6l_endx_nh6|\
+             End_T$seg6l_endt (1-4294967295)$seg6l_endt_table|\
+             End_DX4$seg6l_enddx4 A.B.C.D$seg6l_enddx4_nh4|\
+             End_DT6$seg6l_enddt6 (1-4294967295)$seg6l_enddt6_table>>\
          [backup$backup <A.B.C.D$backup_nexthop4|X:X::X:X$backup_nexthop6>] \
          (1-1000000)$routes [instance (0-255)$instance] [repeat (2-1000)$rpt] [opaque WORD]",
        "Sharp routing Protocol\n"
@@ -204,6 +210,17 @@ DEFPY (install_routes,
        "V6 Nexthop address to use\n"
        "Nexthop-Group to use\n"
        "The Name of the nexthop-group\n"
+       "Nexthop-seg6local to use\n"
+       "Output device to use\n"
+       "SRv6 End function to use\n"
+       "SRv6 End.X function to use\n"
+       "V6 Nexthop address to use\n"
+       "SRv6 End.T function to use\n"
+       "Redirect table id to use\n"
+       "SRv6 End.DX4 function to use\n"
+       "V4 Nexthop address to use\n"
+       "SRv6 End.DT6 function to use\n"
+       "Redirect table id to use\n"
        "Backup nexthop to use(Can be an IPv4 or IPv6 address)\n"
        "Backup V4 Nexthop address to use\n"
        "Backup V6 Nexthop address to use\n"
@@ -291,6 +308,32 @@ DEFPY (install_routes,
                        sg.r.backup_nhop.vrf_id = vrf->vrf_id;
                        sg.r.backup_nhop_group.nexthop = bnhgc->nhg.nexthop;
                }
+       } else if (seg6l_oif) {
+               struct seg6local_context ctx;
+               enum seg6local_action_t action;
+               memset(&ctx, 0, sizeof(struct seg6local_context));
+               if (seg6l_enddx4) {
+                       action = ZEBRA_SEG6_LOCAL_ACTION_END_DX4;
+                       ctx.nh4 = seg6l_enddx4_nh4;
+               } else if (seg6l_endx) {
+                       action = ZEBRA_SEG6_LOCAL_ACTION_END_X;
+                       ctx.nh6 = seg6l_endx_nh6;
+               } else if (seg6l_endt) {
+                       action = ZEBRA_SEG6_LOCAL_ACTION_END_T;
+                       ctx.table = seg6l_endt_table;
+               } else if (seg6l_enddt6) {
+                       action = ZEBRA_SEG6_LOCAL_ACTION_END_DT6;
+                       ctx.table = seg6l_enddt6_table;
+               } else {
+                       action = ZEBRA_SEG6_LOCAL_ACTION_END;
+               }
+
+               sg.r.nhop.type = NEXTHOP_TYPE_IFINDEX;
+               sg.r.nhop.ifindex = ifname2ifindex(seg6l_oif, vrf->vrf_id);
+               sg.r.nhop.vrf_id = vrf->vrf_id;
+               sg.r.nhop_group.nexthop = &sg.r.nhop;
+               nexthop_add_seg6local(&sg.r.nhop, action, &ctx);
+               SET_FLAG(route_flags, ZEBRA_FLAG_SEG6LOCAL_ROUTE);
        } else {
                if (nexthop4.s_addr != INADDR_ANY) {
                        sg.r.nhop.gate.ipv4 = nexthop4;