summaryrefslogtreecommitdiff
path: root/pbrd/pbr_zebra.c
AgeCommit message (Collapse)Author
2020-04-09pbrd: implement `set *` and `match *` config replacementStephen Worley
Implement the ability to replace any existing `set *` or `match` with another one or adding more config without having to first delete the original config already there. Before, we needed to constantly execute a `no` command for everything to remove the rule before making changes to it. With this patch, you can replace configs on individual sequences much easier. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-04-09pbrd: add seqno to debug in pbr_send_pbr_mapStephen Worley
Add some more debug info for the sequence number we are sending to zebra in pbr_send_pbr_map(). Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-03-05*: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__Donatas Abraitis
Just keep the code cool. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-12-09lib, zebra: Allow for encode/decode of nexthop weight in pass downDonald Sharp
Add code to encode/decode the nexthop weight when we pass it down into zebra. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-12-03pbrd: consolidate rule_notify debugs into one callStephen Worley
Consolidate the rule_notify_owner() debugs based on type into one call, making use of zapi_rule_notify_owner2str() to do so. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-12-03pbrd: don't set rule removed on failStephen Worley
Don't treat a remove failure as a successful remove. This can cause us to get out of sync with the kernel. Pbrd makes decisions on rule handling based on its installed state so this needs to be as close to accurate as possible. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-11-21pbrd: Add `set vrf NAME` and `set vrf unchanged`Stephen Worley
`set vrf NAME` allows the pbr map to point to an arbitrary vrf table. `set vrf unchanged` will use the interface's vrf for table lookup. Further, add functionality for pbr to respond to interface events such as interface vrf changes & interface creation/deletion. Ex) ubuntu_nh# show pbr map pbr-map TEST valid: 1 Seq: 1 rule: 300 Installed: 3(1) Reason: Valid SRC Match: 3.3.3.3/32 VRF Unchanged (use interface vrf) pbr-map TEST2 valid: 1 Seq: 2 rule: 301 Installed: 3(2) Reason: Valid SRC Match: 4.4.4.4/32 VRF Lookup: vrf-red root@ubuntu_nh:/home# ip rule show 0: from all lookup local 300: from 3.3.3.3 iif dummy2 lookup main 300: from 3.3.3.3 iif dummyVRF lookup 1111 301: from 4.4.4.4 iif dummy1 lookup 1111 301: from 4.4.4.4 iif dummy3 lookup 1111 Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com-
2019-11-02*: Convert connected_free to a double pointerDonald Sharp
Set the connected pointer to set the pointer to NULL. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-07pbrd: Don't track ipv6 link localsStephen Worley
Don't bother tracking ipv6 link locals to determine if a map should be installed. Every interface has a route of `fe80::/64` so its just going to return the arbitrarily first one it finds when it resolves it and hands it back to us. Instead, just track the interface we specify along with it. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-09-19*: Convert zapi->interface_delete to ifp callbackDonald Sharp
Convert the callback of the interface_delete to the new ifp callback. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19*: Convert interface_down to interface down callbackDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19*: Convert from ->interface_up to the interface callbackDonald Sharp
For all the places we have a zclient->interface_up convert them to use the interface ifp_up callback instead. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19*: Switch all zclient->interface_add to interface create callbackDonald Sharp
Switch the zclient->interface_add functionality to have everyone use the interface create callback in lib/if.c Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19*: Add infrastructure to support zapi interface callbacksDonald Sharp
Start the conversion to allow zapi interface callbacks to be controlled like vrf creation/destruction/change callbacks. This will allow us to consolidate control into the interface.c instead of having each daemon read the stream and react accordingly. This will hopefully reduce a bunch of cut-n-paste stuff Create 4 new callback functions that will be controlled by lib/if.c create -> A upper level protocol receives an interface creation event The ifp is brand spanking newly created in the system. up -> A upper level protocol receives a interface up event This means the interface is up and ready to go. down -> A upper level protocol receives a interface down destroy -> A upper level protocol receives a destroy event This means to delete the pointers associated with it. At this point this is just boilerplate setup for future commits. There is no new functionality. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-03pbrd: initial fwmark support for pbr matches #4460Marcin Matląg
Adds support to specify marks in pbr-map match clause. Marks should be provided as decimal (unsigned int). Currently supported on Linux only. Attempting to configure marks on other platform will result in: "pbr marks are not supported on this platform" Signed-off-by: Marcin Matlag <marcin.matlag@gmail.com> Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2019-05-14lib,bgpd,pbrd: Add AFI_UNSPEC to AFI enumStephen Worley
Add an upspecified option to the AFI enum and update switch statements using it in bgpd and pbrd. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-06Merge pull request #4253 from qlyoung/zapi-handler-args-macroRenato Westphal
ZAPI callback args macro
2019-05-03*: use ZAPI_CALLBACK_ARGS macro for zapi handlersQuentin Young
This macro: - Marks ZAPI callbacks for readability - Standardizes argument names - Makes it simple to add ZAPI arguments in the future - Ensures proper types - Looks better - Shortens function declarations Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-03pbrd: Prevent usage of c if it is nullDonald Sharp
It is possible, that a connected lookup from zebra_interface_address_read is null. Protect and Serve Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-03lib, pbrd, zebra: Fix size_t type printf warnings on obscure platformsDonald Sharp
Use the correct printf formater for those obscure platforms that we build against. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-22Merge pull request #3776 from opensourcerouting/pbrd-interface-nexthopsDonald Sharp
pbrd: add support for interface nexthops
2019-02-14pbrd: add support for interface nexthopsRenato Westphal
Now that nexthop groups can contain interface nexthops, make the necessary adjustments in pbrd to handle them appropriately. For normal IP nexthops, pbrd uses the NHT callbacks to validate these nexthops (i.e. check if they are reachable). NHT can't be used for interface nexthops though. To work around this issue, use the interface event callbacks from the zclient API to validate interface nexthops (an interface nexthop is valid only if the corresponding interface is up and running). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-12pbrd: Do not delete pmi until completion of rule delete.Donald Sharp
When we have a pbr-policy applied to an interface and the rule is installed and then deleted, we would not properly clean up the bit field for the pmi as well as not note the rule as properly deleted. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-12pbrd: Add some missing debugs from external eventsDonald Sharp
Add some debugs from events that can happen that will influence our pbr behavior. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-03pbrd: return check (Coverity 1475199)F. Aragon
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-11-12*: Replace zclient_new with zclient_new_notifyDonald Sharp
It's been a year since we added the new optional parameters to instantiation. Let's switch over to the new name. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-25*: spelchekDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-11*: ALLOC calls cannot failDonald Sharp
There is no need to check for failure of a ALLOC call as that any failure to do so will result in a assert happening. So we can safely remove all of this code. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-25pbrd: add ZAPI_RULE_FAIL_REMOVE flag in switchPhilippe Guibert
The notification handler consecutive to an add/remove of a rule in zebra is being added the FAIL_REMOVE flag. It is mapped on REMOVE flag behaviour for now. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-05-07pbrd: encode null fwmark to be consistent with zebra decode rulePhilippe Guibert
A null 4-byte long fwmark is encoded in pbr rule. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-23pbrd: Fix a couple SA issuesDonald Sharp
1) addr will never be non-null because of the way we build the cli at this point in time, but the SA system does not understand this, add a bread crumb for it. 2) Fix a possible memory leak of the pbr_ifp 3) Fix possible integer overflow when bit shifting. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-17pbrd: Use proper decode function for interfaceDonald Sharp
Use a proper decode function for a interface state change. Ticket: CM-20489 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-17pbrd, zebra: Properly notice rule deletionDonald Sharp
When a rule is deleted properly notice it in pbr. Ticket: CM-20394 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-17pbrd, zebra: Fix multiple pbr-policy installDonald Sharp
Somewhere along the way the ability to install multiple pbr-policys for the same pbr-map was lost. Add this back. There is a limitation in that we are limited to 64 interfaces per pbr-policy. Ticket: CM-20429 Signed-off-by: Donald Sharp sharpd@cumulusnetworks.com>
2018-04-17pbrd: Fix installation and deletion in some casesDonald Sharp
When a nexthop group is modified do not assume that it is not installed. The creation of the pnhgc is enough to set the installed to false. If we are reinstalling it is not needed to set it as not installed. When a pbrms is being installed/removed check to see if it is already installed/deleted and do the right thing from there. Ticket: CM-20371 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-06pbrd: adjust/remove the rule correctly when dst and/or src removedDon Slice
When the last match criteria was removed (dst-ip or src-ip), we were not deleting the rule correctly for ipv6. This fix retains the needed src-ip/dst-ip during the pbr_send_pbr_map process so the appropriate information is available for the rule delete. Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-04-06pbrd: Remove pbr_eventsDonald Sharp
The pbr_events.c file was a mistake in that it overly complicated the code and made it hard to think about what was happening. Remove all the events and just do the work where needed. Additionally rethink the sending of the pbr map to zebra and only send one notification at a time instead of having the sending function attempt to figure out what to do. Clean up some of the no form of commands to make them work properly. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com> Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-04-06pbrd: Cleanup CI warningsDonald Sharp
There are a bunch of CI warnings that need to be cleaned up. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-06pbrd: Add PBR to FRRDonald Sharp
This is an implementation of PBR for FRR. This implemenation uses a combination of rules and tables to determine how packets will flow. PBR introduces a new concept of 'nexthop-groups' to specify a group of nexthops that will be used for ecmp. Nexthop-groups are specified on the cli via: nexthop-group DONNA nexthop 192.168.208.1 nexthop 192.168.209.1 nexthop 192.168.210.1 ! PBR sees the nexthop-group and installs these as a default route with these nexthops starting at table 10000 robot# show pbr nexthop-groups Nexthop-Group: DONNA Table: 10001 Valid: 1 Installed: 1 Valid: 1 nexthop 192.168.209.1 Valid: 1 nexthop 192.168.210.1 Valid: 1 nexthop 192.168.208.1 I have also introduced the ability to specify a table in a 'show ip route table XXX' to see the specified tables. robot# show ip route table 10001 Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, F - PBR, > - selected route, * - FIB route F>* 0.0.0.0/0 [0/0] via 192.168.208.1, enp0s8, 00:14:25 * via 192.168.209.1, enp0s9, 00:14:25 * via 192.168.210.1, enp0s10, 00:14:25 PBR tracks PBR-MAPS via the pbr-map command: ! pbr-map EVA seq 10 match src-ip 4.3.4.0/24 set nexthop-group DONNA ! pbr-map EVA seq 20 match dst-ip 4.3.5.0/24 set nexthop-group DONNA ! pbr-maps can have 'match src-ip <prefix>' and 'match dst-ip <prefix>' to affect decisions about incoming packets. Additionally if you only have one nexthop to use for a pbr-map you do not need to setup a nexthop-group and can specify 'set nexthop XXXX'. To apply the pbr-map to an incoming interface you do this: interface enp0s10 pbr-policy EVA ! When a pbr-map is applied to interfaces it can be installed into the kernel as a rule: [sharpd@robot frr1]$ ip rule show 0: from all lookup local 309: from 4.3.4.0/24 iif enp0s10 lookup 10001 319: from all to 4.3.5.0/24 iif enp0s10 lookup 10001 1000: from all lookup [l3mdev-table] 32766: from all lookup main 32767: from all lookup default [sharpd@robot frr1]$ ip route show table 10001 default proto pbr metric 20 nexthop via 192.168.208.1 dev enp0s8 weight 1 nexthop via 192.168.209.1 dev enp0s9 weight 1 nexthop via 192.168.210.1 dev enp0s10 weight 1 The linux kernel now will use the rules and tables to properly apply these policies. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Signed-off-by: Don Slice <dslice@cumulusnetworks.com> Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>