]> git.proxmox.com Git - mirror_frr.git/blobdiff - sharpd/sharp_vty.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / sharpd / sharp_vty.c
index 3853df7cb08a1b4d754cd29bc183c5140e794645..77b562d6a61ef69023152b8e865e2ef54ad8737e 100644 (file)
@@ -1,23 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * SHARP - vty code
  * Copyright (C) Cumulus Networks, Inc.
  *               Donald Sharp
- *
- * This file is part of FRR.
- *
- * FRR is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * FRR is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include <zebra.h>
 
 #include "linklist.h"
 #include "link_state.h"
 #include "cspf.h"
+#include "tc.h"
 
 #include "sharpd/sharp_globals.h"
 #include "sharpd/sharp_zebra.h"
 #include "sharpd/sharp_nht.h"
 #include "sharpd/sharp_vty.h"
-#ifndef VTYSH_EXTRACT_PL
 #include "sharpd/sharp_vty_clippy.c"
-#endif
 
 DEFINE_MTYPE_STATIC(SHARPD, SRV6_LOCATOR, "SRv6 Locator");
 
@@ -432,7 +416,8 @@ DEFPY (install_seg6local_routes,
              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|\
-             End_DT4$seg6l_enddt4 (1-4294967295)$seg6l_enddt4_table>\
+             End_DT4$seg6l_enddt4 (1-4294967295)$seg6l_enddt4_table|\
+             End_DT46$seg6l_enddt46 (1-4294967295)$seg6l_enddt46_table>\
          (1-1000000)$routes [repeat (2-1000)$rpt]",
        "Sharp routing Protocol\n"
        "install some routes\n"
@@ -453,6 +438,8 @@ DEFPY (install_seg6local_routes,
        "Redirect table id to use\n"
        "SRv6 End.DT4 function to use\n"
        "Redirect table id to use\n"
+       "SRv6 End.DT46 function to use\n"
+       "Redirect table id to use\n"
        "How many to create\n"
        "Should we repeat this command\n"
        "How many times to repeat this command\n")
@@ -508,6 +495,9 @@ DEFPY (install_seg6local_routes,
        } else if (seg6l_enddt4) {
                action = ZEBRA_SEG6_LOCAL_ACTION_END_DT4;
                ctx.table = seg6l_enddt4_table;
+       } else if (seg6l_enddt46) {
+               action = ZEBRA_SEG6_LOCAL_ACTION_END_DT46;
+               ctx.table = seg6l_enddt46_table;
        } else {
                action = ZEBRA_SEG6_LOCAL_ACTION_END;
        }
@@ -615,6 +605,8 @@ DEFUN_NOSH (show_debugging_sharpd,
 {
        vty_out(vty, "Sharp debugging status:\n");
 
+       cmd_show_lib_debugs(vty);
+
        return CMD_SUCCESS;
 }
 
@@ -1333,6 +1325,64 @@ DEFPY (no_sharp_interface_protodown,
        return CMD_SUCCESS;
 }
 
+DEFPY (tc_filter_rate,
+       tc_filter_rate_cmd,
+       "sharp tc dev IFNAME$ifname \
+        source <A.B.C.D/M|X:X::X:X/M>$src \
+        destination <A.B.C.D/M|X:X::X:X/M>$dst \
+        ip-protocol <tcp|udp>$ip_proto \
+        src-port (1-65535)$src_port \
+        dst-port (1-65535)$dst_port \
+        rate RATE$ratestr",
+       SHARP_STR
+       "Traffic control\n"
+       "TC interface (for qdisc, class, filter)\n"
+       "TC interface name\n"
+       "TC filter source\n"
+       "TC filter source IPv4 prefix\n"
+       "TC filter source IPv6 prefix\n"
+       "TC filter destination\n"
+       "TC filter destination IPv4 prefix\n"
+       "TC filter destination IPv6 prefix\n"
+       "TC filter IP protocol\n"
+       "TC filter IP protocol TCP\n"
+       "TC filter IP protocol UDP\n"
+       "TC filter source port\n"
+       "TC filter source port\n"
+       "TC filter destination port\n"
+       "TC filter destination port\n"
+       "TC rate\n"
+       "TC rate number (bits/s) or rate string (suffixed with Bps or bit)\n")
+{
+       struct interface *ifp;
+       struct protoent *p;
+       uint64_t rate;
+
+       ifp = if_lookup_vrf_all(ifname);
+
+       if (!ifp) {
+               vty_out(vty, "%% Can't find interface %s\n", ifname);
+               return CMD_WARNING;
+       }
+
+       p = getprotobyname(ip_proto);
+       if (!p) {
+               vty_out(vty, "Unable to convert %s to proto id\n", ip_proto);
+               return CMD_WARNING;
+       }
+
+       if (tc_getrate(ratestr, &rate) != 0) {
+               vty_out(vty, "Unable to convert %s to rate\n", ratestr);
+               return CMD_WARNING;
+       }
+
+       if (sharp_zebra_send_tc_filter_rate(ifp, src, dst, p->p_proto, src_port,
+                                           dst_port, rate) != 0)
+               return CMD_WARNING;
+
+       return CMD_SUCCESS;
+}
+
 void sharp_vty_init(void)
 {
        install_element(ENABLE_NODE, &install_routes_data_dump_cmd);
@@ -1368,5 +1418,7 @@ void sharp_vty_init(void)
        install_element(ENABLE_NODE, &sharp_interface_protodown_cmd);
        install_element(ENABLE_NODE, &no_sharp_interface_protodown_cmd);
 
+       install_element(ENABLE_NODE, &tc_filter_rate_cmd);
+
        return;
 }