+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* PBR - vty code
* Copyright (C) 2018 Cumulus Networks, Inc.
* Donald Sharp
- *
- * 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 "pbrd/pbr_zebra.h"
#include "pbrd/pbr_vty.h"
#include "pbrd/pbr_debug.h"
-#ifndef VTYSH_EXTRACT_PL
#include "pbrd/pbr_vty_clippy.c"
-#endif
DEFUN_NOSH(pbr_map, pbr_map_cmd, "pbr-map PBRMAP seq (1-700)",
"Create pbr-map or enter pbr-map command mode\n"
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
if (pbrms->dst && pbrms->family && prefix->family != pbrms->family) {
vty_out(vty, "Cannot mismatch families within match src/dst\n");
return CMD_WARNING_CONFIG_FAILED;
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
if (pbrms->src && pbrms->family && prefix->family != pbrms->family) {
vty_out(vty, "Cannot mismatch families within match src/dst\n");
return CMD_WARNING_CONFIG_FAILED;
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
struct protoent *p;
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
if (!no) {
p = getprotobyname(ip_proto);
if (!p) {
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
if (!no) {
if (pbrms->src_prt == port)
return CMD_SUCCESS;
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
if (!no) {
if (pbrms->dst_prt == port)
return CMD_SUCCESS;
char dscpname[100];
uint8_t rawDscp;
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
/* Discriminate dscp enums (cs0, cs1 etc.) and numbers */
bool isANumber = true;
for (int i = 0; i < (int)strlen(dscp); i++) {
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
if (!no) {
if ((pbrms->dsfield & PBR_DSFIELD_ECN) == ecn)
return CMD_SUCCESS;
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
#ifndef GNU_LINUX
- vty_out(vty, "pbr marks are not supported on this platform");
+ vty_out(vty, "pbr marks are not supported on this platform\n");
return CMD_WARNING_CONFIG_FAILED;
#endif
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
if (!no)
pbrms->action_queue_id = queue_id;
else if ((uint32_t)queue_id == pbrms->action_queue_id)
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
if (!no)
pbrms->action_pcp = pcp;
else if (pcp == pbrms->action_pcp)
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
if (!no)
pbrms->action_vlan_id = vlan_id;
else if (pbrms->action_vlan_id == vlan_id)
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
if (!no)
pbrms->action_vlan_flags = PBR_MAP_STRIP_INNER_ANY;
else
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
struct nexthop_group_cmd *nhgc;
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
nhgc = nhgc_find(name);
if (!nhgc) {
vty_out(vty, "Specified nexthop-group %s does not exist\n",
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
pbrms_clear_set_config(pbrms);
return CMD_SUCCESS;
struct nexthop nhop;
struct nexthop *nh = NULL;
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
if (vrf_name)
vrf = vrf_lookup_by_name(vrf_name);
else
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
pbrms_clear_set_config(pbrms);
return CMD_SUCCESS;
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
/*
* If an equivalent set vrf * exists, just return success.
*/
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+ if (!pbrms)
+ return CMD_WARNING_CONFIG_FAILED;
+
pbrms_clear_set_config(pbrms);
return CMD_SUCCESS;
}
if (pbrms->src)
- vty_out(vty, " SRC Match: %pFX\n", pbrms->src);
+ vty_out(vty, " SRC IP Match: %pFX\n", pbrms->src);
if (pbrms->dst)
- vty_out(vty, " DST Match: %pFX\n", pbrms->dst);
+ vty_out(vty, " DST IP Match: %pFX\n", pbrms->dst);
+ if (pbrms->src_prt)
+ vty_out(vty, " SRC Port Match: %u\n", pbrms->src_prt);
+ if (pbrms->dst_prt)
+ vty_out(vty, " DST Port Match: %u\n", pbrms->dst_prt);
if (pbrms->dsfield & PBR_DSFIELD_DSCP)
vty_out(vty, " DSCP Match: %u\n",
(pbrms->dsfield & PBR_DSFIELD_DSCP) >> 2);
if (detail)
vty_out(vty,
- " Installed: %u(%d) Tableid: %d\n",
+ " Installed: %u(%d) Tableid: %u\n",
pbrms->nhs_installed,
pbr_nht_get_installed(pbrms->nhgrp_name),
pbr_nht_get_table(pbrms->nhgrp_name));
else
- vty_out(vty, " Installed: %s Tableid: %d\n",
+ vty_out(vty, " Installed: %s Tableid: %u\n",
pbr_nht_get_installed(pbrms->nhgrp_name) ? "yes"
: "no",
pbr_nht_get_table(pbrms->nhgrp_name));
pbrms_nexthop_group_write_individual_nexthop(vty, pbrms);
if (detail)
vty_out(vty,
- " Installed: %u(%d) Tableid: %d\n",
+ " Installed: %u(%d) Tableid: %u\n",
pbrms->nhs_installed,
pbr_nht_get_installed(pbrms->internal_nhg_name),
pbr_nht_get_table(pbrms->internal_nhg_name));
else
- vty_out(vty, " Installed: %s Tableid: %d\n",
+ vty_out(vty, " Installed: %s Tableid: %u\n",
pbr_nht_get_installed(pbrms->internal_nhg_name)
? "yes"
: "no",
pbr_debug_config_write_helper(vty, false);
+ cmd_show_lib_debugs(vty);
+
return CMD_SUCCESS;
}