+// 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");
memset(&prefix, 0, sizeof(prefix));
memset(&sg.r.orig_prefix, 0, sizeof(sg.r.orig_prefix));
+ nexthop_del_srv6_seg6local(&sg.r.nhop);
+ nexthop_del_srv6_seg6(&sg.r.nhop);
memset(&sg.r.nhop, 0, sizeof(sg.r.nhop));
memset(&sg.r.nhop_group, 0, sizeof(sg.r.nhop_group));
memset(&sg.r.backup_nhop, 0, sizeof(sg.r.nhop));
memset(&prefix, 0, sizeof(prefix));
memset(&sg.r.orig_prefix, 0, sizeof(sg.r.orig_prefix));
+ nexthop_del_srv6_seg6local(&sg.r.nhop);
+ nexthop_del_srv6_seg6(&sg.r.nhop);
memset(&sg.r.nhop, 0, sizeof(sg.r.nhop));
memset(&sg.r.nhop_group, 0, sizeof(sg.r.nhop_group));
memset(&sg.r.backup_nhop, 0, sizeof(sg.r.nhop));
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"
"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")
sg.r.repeat = 0;
memset(&sg.r.orig_prefix, 0, sizeof(sg.r.orig_prefix));
+ nexthop_del_srv6_seg6local(&sg.r.nhop);
+ nexthop_del_srv6_seg6(&sg.r.nhop);
memset(&sg.r.nhop, 0, sizeof(sg.r.nhop));
memset(&sg.r.nhop_group, 0, sizeof(sg.r.nhop_group));
memset(&sg.r.backup_nhop, 0, sizeof(sg.r.nhop));
} 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;
}
{
vty_out(vty, "Sharp debugging status:\n");
+ cmd_show_lib_debugs(vty);
+
return CMD_SUCCESS;
}
return CMD_SUCCESS;
}
+static void sharp_srv6_locator_chunk_free(struct prefix_ipv6 *chunk)
+{
+ prefix_ipv6_free((struct prefix_ipv6 **)&chunk);
+}
+
DEFPY (sharp_srv6_manager_get_locator_chunk,
sharp_srv6_manager_get_locator_chunk_cmd,
"sharp srv6-manager get-locator-chunk NAME$locator_name",
loc = XCALLOC(MTYPE_SRV6_LOCATOR,
sizeof(struct sharp_srv6_locator));
loc->chunks = list_new();
+ loc->chunks->del =
+ (void (*)(void *))sharp_srv6_locator_chunk_free;
snprintf(loc->name, SRV6_LOCNAME_SIZE, "%s", locator_name);
listnode_add(sg.srv6_locators, loc);
}
list_delete_all_node(loc->chunks);
list_delete(&loc->chunks);
listnode_delete(sg.srv6_locators, loc);
+ XFREE(MTYPE_SRV6_LOCATOR, loc);
break;
}
}
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);
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;
}