mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 16:04:49 +00:00
commit
5bee21f37c
@ -521,10 +521,12 @@ generic_match_add (struct vty *vty, struct route_map_index *index,
|
|||||||
switch (ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
case RMAP_RULE_MISSING:
|
case RMAP_RULE_MISSING:
|
||||||
vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
|
vty_out (vty, "%% [%s] Can't find rule.%s", frr_protonameinst,
|
||||||
|
VTY_NEWLINE);
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
case RMAP_COMPILE_ERROR:
|
case RMAP_COMPILE_ERROR:
|
||||||
vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
|
vty_out (vty, "%% [%s] Argument form is unsupported or malformed.%s",
|
||||||
|
frr_protonameinst, VTY_NEWLINE);
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -567,10 +569,12 @@ generic_match_delete (struct vty *vty, struct route_map_index *index,
|
|||||||
switch (ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
case RMAP_RULE_MISSING:
|
case RMAP_RULE_MISSING:
|
||||||
vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE);
|
vty_out (vty, "%% [%s] Can't find rule.%s", frr_protonameinst,
|
||||||
|
VTY_NEWLINE);
|
||||||
break;
|
break;
|
||||||
case RMAP_COMPILE_ERROR:
|
case RMAP_COMPILE_ERROR:
|
||||||
vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE);
|
vty_out (vty, "%% [%s] Argument form is unsupported or malformed.%s",
|
||||||
|
frr_protonameinst, VTY_NEWLINE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (dep_name)
|
if (dep_name)
|
||||||
@ -603,10 +607,12 @@ generic_set_add (struct vty *vty, struct route_map_index *index,
|
|||||||
switch (ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
case RMAP_RULE_MISSING:
|
case RMAP_RULE_MISSING:
|
||||||
vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
|
vty_out (vty, "%% [%s] Can't find rule.%s", frr_protonameinst,
|
||||||
|
VTY_NEWLINE);
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
case RMAP_COMPILE_ERROR:
|
case RMAP_COMPILE_ERROR:
|
||||||
vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
|
vty_out (vty, "%% [%s] Argument form is unsupported or malformed.%s",
|
||||||
|
frr_protonameinst, VTY_NEWLINE);
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -625,10 +631,12 @@ generic_set_delete (struct vty *vty, struct route_map_index *index,
|
|||||||
switch (ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
case RMAP_RULE_MISSING:
|
case RMAP_RULE_MISSING:
|
||||||
vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
|
vty_out (vty, "%% [%s] Can't find rule.%s", frr_protonameinst,
|
||||||
|
VTY_NEWLINE);
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
case RMAP_COMPILE_ERROR:
|
case RMAP_COMPILE_ERROR:
|
||||||
vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
|
vty_out (vty, "%% [%s] Argument form is unsupported or malformed.%s",
|
||||||
|
frr_protonameinst, VTY_NEWLINE);
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2464,8 +2472,11 @@ DEFUN (set_metric,
|
|||||||
int idx_number = 2;
|
int idx_number = 2;
|
||||||
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
||||||
|
|
||||||
|
const char *pass = (argv[idx_number]->type == RANGE_TKN) ?
|
||||||
|
argv[idx_number]->arg : argv[idx_number]->text;
|
||||||
|
|
||||||
if (rmap_match_set_hook.set_metric)
|
if (rmap_match_set_hook.set_metric)
|
||||||
return rmap_match_set_hook.set_metric (vty, index, "metric", argv[idx_number]->arg);
|
return rmap_match_set_hook.set_metric (vty, index, "metric", pass);
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2595,7 +2606,8 @@ DEFUN (no_route_map,
|
|||||||
struct route_map *map;
|
struct route_map *map;
|
||||||
struct route_map_index *index;
|
struct route_map_index *index;
|
||||||
char *endptr = NULL;
|
char *endptr = NULL;
|
||||||
int permit = argv[idx_permit_deny]->arg[0] == 'p' ? RMAP_PERMIT : RMAP_DENY;
|
int permit = strmatch (argv[idx_permit_deny]->text, "permit") ?
|
||||||
|
RMAP_PERMIT : RMAP_DENY;
|
||||||
const char *prefstr = argv[idx_number]->arg;
|
const char *prefstr = argv[idx_number]->arg;
|
||||||
const char *mapname = argv[idx_word]->arg;
|
const char *mapname = argv[idx_word]->arg;
|
||||||
unsigned long pref = strtoul (prefstr, &endptr, 10);
|
unsigned long pref = strtoul (prefstr, &endptr, 10);
|
||||||
|
@ -117,55 +117,6 @@ ospf_route_map_event (route_map_event_t event, const char *name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete rip route map rule. */
|
|
||||||
static int
|
|
||||||
ospf_route_match_delete (struct vty *vty,
|
|
||||||
const char *command, const char *arg)
|
|
||||||
{
|
|
||||||
VTY_DECLVAR_CONTEXT(route_map_index, index);
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = route_map_delete_match (index, command, arg);
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
switch (ret)
|
|
||||||
{
|
|
||||||
case RMAP_RULE_MISSING:
|
|
||||||
vty_out (vty, "%% OSPF Can't find rule.%s", VTY_NEWLINE);
|
|
||||||
return CMD_WARNING;
|
|
||||||
case RMAP_COMPILE_ERROR:
|
|
||||||
vty_out (vty, "%% OSPF Argument is malformed.%s", VTY_NEWLINE);
|
|
||||||
return CMD_WARNING;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ospf_route_match_add (struct vty *vty,
|
|
||||||
const char *command, const char *arg)
|
|
||||||
{
|
|
||||||
VTY_DECLVAR_CONTEXT(route_map_index, index);
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = route_map_add_match (index, command, arg);
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
switch (ret)
|
|
||||||
{
|
|
||||||
case RMAP_RULE_MISSING:
|
|
||||||
vty_out (vty, "%% OSPF Can't find rule.%s", VTY_NEWLINE);
|
|
||||||
return CMD_WARNING;
|
|
||||||
case RMAP_COMPILE_ERROR:
|
|
||||||
vty_out (vty, "%% OSPF Argument is malformed.%s", VTY_NEWLINE);
|
|
||||||
return CMD_WARNING;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* `match ip netxthop ' */
|
/* `match ip netxthop ' */
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t
|
static route_map_result_t
|
||||||
@ -449,35 +400,28 @@ static void *
|
|||||||
route_set_metric_compile (const char *arg)
|
route_set_metric_compile (const char *arg)
|
||||||
{
|
{
|
||||||
u_int32_t *metric;
|
u_int32_t *metric;
|
||||||
int32_t ret;
|
|
||||||
|
|
||||||
/* OSPF doesn't support the +/- in
|
/* OSPF doesn't support the +/- in
|
||||||
set metric <+/-metric> check
|
set metric <+/-metric> check
|
||||||
Ignore the +/- component */
|
Ignore the +/- component */
|
||||||
if (! all_digit (arg))
|
if (! all_digit (arg))
|
||||||
{
|
{
|
||||||
if ((strncmp (arg, "+", 1) == 0 || strncmp (arg, "-", 1) == 0) &&
|
if ((arg[0] == '+' || arg[0] == '-') && all_digit (arg+1))
|
||||||
all_digit (arg+1))
|
|
||||||
{
|
{
|
||||||
zlog_warn ("OSPF does not support 'set metric +/-'");
|
zlog_warn ("OSPF does not support 'set metric +/-'");
|
||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return NULL;
|
if (strmatch (arg, "+rtt") || strmatch (arg, "-rtt"))
|
||||||
}
|
zlog_warn ("OSPF does not support 'set metric +rtt / -rtt'");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
metric = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
|
metric = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
|
||||||
ret = atoi (arg);
|
*metric = strtoul (arg, NULL, 10);
|
||||||
|
|
||||||
if (ret >= 0)
|
return metric;
|
||||||
{
|
|
||||||
*metric = (u_int32_t)ret;
|
|
||||||
return metric;
|
|
||||||
}
|
|
||||||
|
|
||||||
XFREE (MTYPE_ROUTE_MAP_COMPILED, metric);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free route map's compiled `set metric' value. */
|
/* Free route map's compiled `set metric' value. */
|
||||||
@ -581,35 +525,6 @@ static struct route_map_rule_cmd route_set_tag_cmd =
|
|||||||
route_map_rule_tag_free,
|
route_map_rule_tag_free,
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFUN (match_ip_nexthop,
|
|
||||||
match_ip_nexthop_cmd,
|
|
||||||
"match ip next-hop <(1-199)|(1300-2699)|WORD>",
|
|
||||||
MATCH_STR
|
|
||||||
IP_STR
|
|
||||||
"Match next-hop address of route\n"
|
|
||||||
"IP access-list number\n"
|
|
||||||
"IP access-list number (expanded range)\n"
|
|
||||||
"IP access-list name\n")
|
|
||||||
{
|
|
||||||
int idx_acl = 3;
|
|
||||||
return ospf_route_match_add (vty, "ip next-hop", argv[idx_acl]->arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFUN (no_match_ip_nexthop,
|
|
||||||
no_match_ip_nexthop_cmd,
|
|
||||||
"no match ip next-hop [<(1-199)|(1300-2699)|WORD>]",
|
|
||||||
NO_STR
|
|
||||||
MATCH_STR
|
|
||||||
IP_STR
|
|
||||||
"Match next-hop address of route\n"
|
|
||||||
"IP access-list number\n"
|
|
||||||
"IP access-list number (expanded range)\n"
|
|
||||||
"IP access-list name\n")
|
|
||||||
{
|
|
||||||
char *al = (argc == 5) ? argv[4]->arg : NULL;
|
|
||||||
return ospf_route_match_delete (vty, "ip next-hop", al);
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFUN (set_metric_type,
|
DEFUN (set_metric_type,
|
||||||
set_metric_type_cmd,
|
set_metric_type_cmd,
|
||||||
"set metric-type <type-1|type-2>",
|
"set metric-type <type-1|type-2>",
|
||||||
@ -647,6 +562,12 @@ ospf_route_map_init (void)
|
|||||||
route_map_delete_hook (ospf_route_map_update);
|
route_map_delete_hook (ospf_route_map_update);
|
||||||
route_map_event_hook (ospf_route_map_event);
|
route_map_event_hook (ospf_route_map_event);
|
||||||
|
|
||||||
|
route_map_set_metric_hook (generic_set_add);
|
||||||
|
route_map_no_set_metric_hook (generic_set_delete);
|
||||||
|
|
||||||
|
route_map_match_ip_next_hop_hook (generic_match_add);
|
||||||
|
route_map_no_match_ip_next_hop_hook (generic_match_delete);
|
||||||
|
|
||||||
route_map_match_interface_hook (generic_match_add);
|
route_map_match_interface_hook (generic_match_add);
|
||||||
route_map_no_match_interface_hook (generic_match_delete);
|
route_map_no_match_interface_hook (generic_match_delete);
|
||||||
|
|
||||||
@ -679,9 +600,6 @@ ospf_route_map_init (void)
|
|||||||
route_map_install_set (&route_set_metric_type_cmd);
|
route_map_install_set (&route_set_metric_type_cmd);
|
||||||
route_map_install_set (&route_set_tag_cmd);
|
route_map_install_set (&route_set_tag_cmd);
|
||||||
|
|
||||||
install_element (RMAP_NODE, &match_ip_nexthop_cmd);
|
|
||||||
install_element (RMAP_NODE, &no_match_ip_nexthop_cmd);
|
|
||||||
|
|
||||||
install_element (RMAP_NODE, &set_metric_type_cmd);
|
install_element (RMAP_NODE, &set_metric_type_cmd);
|
||||||
install_element (RMAP_NODE, &no_set_metric_type_cmd);
|
install_element (RMAP_NODE, &no_set_metric_type_cmd);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user