diff options
author | Pascal Mathis <mail@pascalmathis.com> | 2018-05-27 17:39:45 +0200 |
---|---|---|
committer | Pascal Mathis <mail@pascalmathis.com> | 2018-05-28 19:20:25 +0200 |
commit | 27c05d4d43d14464b15582c700a511156c4ea2af (patch) | |
tree | e43a7f7624389b6a30bc7c241b8fee3577ba3ea1 /bgpd/bgp_vty.c | |
parent | bgpd: Improve group overrides for AF filters (diff) | |
download | frr-27c05d4d43d14464b15582c700a511156c4ea2af.tar.xz frr-27c05d4d43d14464b15582c700a511156c4ea2af.zip |
bgpd: Fix group overrides for inverted AF flags
This commit fixes peer-group overrides for inverted AF flags. This
implementation is currently only being used by the three 'send-community'
flags. Commit 70ee29b4d introduced generic support for overriding AF
flags, but did not support inverted flags.
By introducing an additional array on the BGP peer structure called
'af_flags_invert' all current and future flags which should work in an
inverted way can now also be properly overridden.
The CLI commands will work exactly the same way as before, just that 'no
<command>' now sets the flag and override whereas '<command>' will unset
the flag and remove the override.
Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
Diffstat (limited to 'bgpd/bgp_vty.c')
-rw-r--r-- | bgpd/bgp_vty.c | 63 |
1 files changed, 29 insertions, 34 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 257adda3f..f83f357e5 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -4073,6 +4073,7 @@ DEFUN (neighbor_send_community, "Send Community attribute to this neighbor\n") { int idx_peer = 1; + return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), PEER_FLAG_SEND_COMMUNITY); @@ -4092,6 +4093,7 @@ DEFUN (no_neighbor_send_community, "Send Community attribute to this neighbor\n") { int idx_peer = 2; + return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), PEER_FLAG_SEND_COMMUNITY); @@ -4115,27 +4117,26 @@ DEFUN (neighbor_send_community_type, "Send Standard Community attributes\n" "Send Large Community attributes\n") { - int idx = 0; + int idx_peer = 1; uint32_t flag = 0; + const char *type = argv[argc - 1]->text; - char *peer = argv[1]->arg; - - if (argv_find(argv, argc, "standard", &idx)) + if (strmatch(type, "standard")) { SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); - else if (argv_find(argv, argc, "extended", &idx)) + } else if (strmatch(type, "extended")) { SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); - else if (argv_find(argv, argc, "large", &idx)) + } else if (strmatch(type, "large")) { SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); - else if (argv_find(argv, argc, "both", &idx)) { + } else if (strmatch(type, "both")) { SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); - } else { + } else { /* if (strmatch(type, "all")) */ SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); } - return peer_af_flag_set_vty(vty, peer, bgp_node_afi(vty), + return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), flag); } @@ -4164,33 +4165,27 @@ DEFUN (no_neighbor_send_community_type, "Send Large Community attributes\n") { int idx_peer = 2; - + uint32_t flag = 0; const char *type = argv[argc - 1]->text; - if (strmatch(type, "standard")) - return peer_af_flag_unset_vty( - vty, argv[idx_peer]->arg, bgp_node_afi(vty), - bgp_node_safi(vty), PEER_FLAG_SEND_COMMUNITY); - if (strmatch(type, "extended")) - return peer_af_flag_unset_vty( - vty, argv[idx_peer]->arg, bgp_node_afi(vty), - bgp_node_safi(vty), PEER_FLAG_SEND_EXT_COMMUNITY); - if (strmatch(type, "large")) - return peer_af_flag_unset_vty( - vty, argv[idx_peer]->arg, bgp_node_afi(vty), - bgp_node_safi(vty), PEER_FLAG_SEND_LARGE_COMMUNITY); - if (strmatch(type, "both")) - return peer_af_flag_unset_vty( - vty, argv[idx_peer]->arg, bgp_node_afi(vty), - bgp_node_safi(vty), - PEER_FLAG_SEND_COMMUNITY - | PEER_FLAG_SEND_EXT_COMMUNITY); - - /* if (strmatch (type, "all")) */ - return peer_af_flag_unset_vty( - vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), - (PEER_FLAG_SEND_COMMUNITY | PEER_FLAG_SEND_EXT_COMMUNITY - | PEER_FLAG_SEND_LARGE_COMMUNITY)); + if (strmatch(type, "standard")) { + SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); + } else if (strmatch(type, "extended")) { + SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); + } else if (strmatch(type, "large")) { + SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); + } else if (strmatch(type, "both")) { + SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); + SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); + } else { /* if (strmatch(type, "all")) */ + SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); + SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); + SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); + } + + return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, + bgp_node_afi(vty), bgp_node_safi(vty), + flag); } ALIAS_HIDDEN( |