Skip to content

Commit

Permalink
Merge pull request #8040 from donaldsharp/fix_distribute
Browse files Browse the repository at this point in the history
  • Loading branch information
idryzhov authored May 5, 2021
2 parents 731849d + 8a7be4d commit 5d421ab
Show file tree
Hide file tree
Showing 12 changed files with 291 additions and 182 deletions.
94 changes: 91 additions & 3 deletions babeld/babeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,92 @@ DEFUN (babel_set_smoothing_half_life,
return CMD_SUCCESS;
}

DEFUN (babel_distribute_list,
babel_distribute_list_cmd,
"distribute-list [prefix] WORD <in|out> [WORD]",
"Filter networks in routing updates\n"
"Specify a prefix\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
const char *ifname = NULL;
int prefix = (argv[1]->type == WORD_TKN) ? 1 : 0;

if (argv[argc - 1]->type == VARIABLE_TKN)
ifname = argv[argc - 1]->arg;

return distribute_list_parser(prefix, true, argv[2 + prefix]->text,
argv[1 + prefix]->arg, ifname);
}

DEFUN (babel_no_distribute_list,
babel_no_distribute_list_cmd,
"no distribute-list [prefix] WORD <in|out> [WORD]",
NO_STR
"Filter networks in routing updates\n"
"Specify a prefix\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
const char *ifname = NULL;
int prefix = (argv[2]->type == WORD_TKN) ? 1 : 0;

if (argv[argc - 1]->type == VARIABLE_TKN)
ifname = argv[argc - 1]->arg;

return distribute_list_no_parser(vty, prefix, true,
argv[3 + prefix]->text,
argv[2 + prefix]->arg, ifname);
}

DEFUN (babel_ipv6_distribute_list,
babel_ipv6_distribute_list_cmd,
"ipv6 distribute-list [prefix] WORD <in|out> [WORD]",
"IPv6\n"
"Filter networks in routing updates\n"
"Specify a prefix\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
const char *ifname = NULL;
int prefix = (argv[2]->type == WORD_TKN) ? 1 : 0;

if (argv[argc - 1]->type == VARIABLE_TKN)
ifname = argv[argc - 1]->arg;

return distribute_list_parser(prefix, false, argv[3 + prefix]->text,
argv[2 + prefix]->arg, ifname);
}

DEFUN (babel_no_ipv6_distribute_list,
babel_no_ipv6_distribute_list_cmd,
"no ipv6 distribute-list [prefix] WORD <in|out> [WORD]",
NO_STR
"IPv6\n"
"Filter networks in routing updates\n"
"Specify a prefix\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
const char *ifname = NULL;
int prefix = (argv[3]->type == WORD_TKN) ? 1 : 0;

if (argv[argc - 1]->type == VARIABLE_TKN)
ifname = argv[argc - 1]->arg;

return distribute_list_no_parser(vty, prefix, false,
argv[4 + prefix]->text,
argv[3 + prefix]->arg, ifname);
}

void
babeld_quagga_init(void)
{
Expand All @@ -728,6 +814,11 @@ babeld_quagga_init(void)
install_element(BABEL_NODE, &babel_set_resend_delay_cmd);
install_element(BABEL_NODE, &babel_set_smoothing_half_life_cmd);

install_element(BABEL_NODE, &babel_distribute_list_cmd);
install_element(BABEL_NODE, &babel_no_distribute_list_cmd);
install_element(BABEL_NODE, &babel_ipv6_distribute_list_cmd);
install_element(BABEL_NODE, &babel_no_ipv6_distribute_list_cmd);

babel_if_init();

/* Access list install. */
Expand All @@ -739,9 +830,6 @@ babeld_quagga_init(void)
prefix_list_init ();
prefix_list_add_hook (babel_distribute_update_all);
prefix_list_delete_hook (babel_distribute_update_all);

/* Distribute list install. */
distribute_list_init(BABEL_NODE);
}

/* Stubs to adapt Babel's filtering calls to Quagga's infrastructure. */
Expand Down
15 changes: 5 additions & 10 deletions doc/user/ripd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,13 @@ Filtering RIP Routes

RIP routes can be filtered by a distribute-list.

.. clicmd:: distribute-list ACCESS_LIST DIRECT IFNAME
.. clicmd:: distribute-list [prefix] LIST <in|out> IFNAME

You can apply access lists to the interface with a `distribute-list` command.
ACCESS_LIST is the access list name. DIRECT is ``in`` or ``out``. If DIRECT
is ``in`` the access list is applied to input packets.
If prefix is specified LIST is a prefix-list. If prefix is not specified
then LIST is the access list name. `in` specifies packets being received,
and `out` specifies outgoing packets. Finally if an interface is specified
it will be applied against a specific interface.

The `distribute-list` command can be used to filter the RIP path.
`distribute-list` can apply access-lists to a chosen interface. First, one
Expand All @@ -261,13 +263,6 @@ RIP routes can be filtered by a distribute-list.
`distribute-list` can be applied to both incoming and outgoing data.

.. clicmd:: distribute-list prefix PREFIX_LIST (in|out) IFNAME

You can apply prefix lists to the interface with a `distribute-list`
command. PREFIX_LIST is the prefix list name. Next is the direction of
``in`` or ``out``. If DIRECT is ``in`` the access list is applied to input
packets.

.. _rip-metric-manipulation:

RIP Metric Manipulation
Expand Down
32 changes: 26 additions & 6 deletions doc/user/ripngd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,34 @@ ripngd Terminal Mode Commands
ripngd Filtering Commands
=========================

.. clicmd:: distribute-list ACCESS_LIST (in|out) IFNAME
RIPng routes can be filtered by a distribute-list.

You can apply an access-list to the interface using the `distribute-list`
command. ACCESS_LIST is an access-list name. `direct` is ``in`` or
``out``. If `direct` is ``in``, the access-list is applied only to incoming
packets.::
.. clicmd:: distribute-list [prefix] LIST <in|out> IFNAME

distribute-list local-only out sit1
You can apply access lists to the interface with a `distribute-list` command.
If prefix is specified LIST is a prefix-list. If prefix is not specified
then LIST is the access list name. `in` specifies packets being received,
and `out` specifies outgoing packets. Finally if an interface is specified
it will be applied against a specific interface.

The ``distribute-list`` command can be used to filter the RIPNG path.
``distribute-list`` can apply access-lists to a chosen interface. First, one
should specify the access-list. Next, the name of the access-list is used in
the distribute-list command. For example, in the following configuration
``eth0`` will permit only the paths that match the route 10.0.0.0/8

.. code-block:: frr
!
router ripng
distribute-list private in eth0
!
access-list private permit 10 10.0.0.0/8
access-list private deny any
!
`distribute-list` can be applied to both incoming and outgoing data.


Sample configuration
Expand Down
2 changes: 0 additions & 2 deletions eigrpd/eigrp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ int main(int argc, char **argv, char **envp)
route_map_add_hook (eigrp_rmap_update);
route_map_delete_hook (eigrp_rmap_update);*/
/*if_rmap_init (EIGRP_NODE); */
/* Distribute list install. */
distribute_list_init(EIGRP_NODE);

frr_config_fork();
frr_run(master);
Expand Down
45 changes: 45 additions & 0 deletions eigrpd/eigrp_routemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,48 @@ ALIAS(no_set_tag, no_set_tag_val_cmd, "no set tag (0-65535)", NO_STR SET_STR
"Tag value for routing protocol\n"
"Tag value\n")

DEFUN (eigrp_distribute_list,
eigrp_distribute_list_cmd,
"distribute-list [prefix] WORD <in|out> [WORD]",
"Filter networks in routing updates\n"
"Specify a prefix\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
const char *ifname = NULL;
int prefix = (argv[1]->type == WORD_TKN) ? 1 : 0;

if (argv[argc - 1]->type == VARIABLE_TKN)
ifname = argv[argc - 1]->arg;

return distribute_list_parser(prefix, true, argv[2 + prefix]->text,
argv[1 + prefix]->arg, ifname);
}

DEFUN (eigrp_no_distribute_list,
eigrp_no_distribute_list_cmd,
"no distribute-list [prefix] WORD <in|out> [WORD]",
NO_STR
"Filter networks in routing updates\n"
"Specify a prefix\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
const char *ifname = NULL;
int prefix = (argv[2]->type == WORD_TKN) ? 1 : 0;

if (argv[argc - 1]->type == VARIABLE_TKN)
ifname = argv[argc - 1]->arg;

return distribute_list_no_parser(vty, prefix, true,
argv[3 + prefix]->text,
argv[2 + prefix]->arg, ifname);
}


/* Route-map init */
void eigrp_route_map_init()
Expand All @@ -1139,6 +1181,9 @@ void eigrp_route_map_init()
route_map_add_hook(eigrp_route_map_update);
route_map_delete_hook(eigrp_route_map_update);

install_element(EIGRP_NODE, &eigrp_distribute_list_cmd);
install_element(EIGRP_NODE, &eigrp_no_distribute_list_cmd);

/*route_map_install_match (&route_match_metric_cmd);
route_map_install_match (&route_match_interface_cmd);*/
/*route_map_install_match (&route_match_ip_next_hop_cmd);
Expand Down
Loading

0 comments on commit 5d421ab

Please sign in to comment.