Commit Graph

70 Commits

Author SHA1 Message Date
Quentin Young
bf094f6975 zebra: clean up zapi organization
zserv.c has become something of a dumping ground for everything vaguely
related to ZAPI and really needs some love. This change splits out the
code fo building and consuming ZAPI messages into a separate source
file, leaving the actual session and client lifecycle code in zserv.c.

Unfortunately since the #include situation in Zebra has not been paid
much attention I was forced to fix the headers in a lot of other source
files. This is a net improvement overall though.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-22 22:50:24 -04:00
Donald Sharp
0f03639ded pbrd, zebra: Properly notice rule deletion
When a rule is deleted properly notice it in pbr.

Ticket: CM-20394
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-17 18:43:47 -04:00
Donald Sharp
37c606ffbf pbrd, zebra: Fix multiple pbr-policy install
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-17 18:43:46 -04:00
Philippe Guibert
f46bbab419 zebra: rename pbr_unique structure to pbr_rule_unique
This renaming of structure permits better identify which structure is
looked up, since policy routing will not only rely on iprule, but also
on some other structures.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-16 14:40:43 +02:00
Philippe Guibert
5dd0722dcf zebra: adapt zebra_pbr_rule based with pbr_rule
In order to avoid duplicates functions, the zebra_pbr_rule structure
used by zebra to decode the zapi message, and send netlink messages, is
slightly modified. the structure is derived from pbr_rule, but it also
includes sock identifier that is used to send back information to the
daemon that did the request. Also, the ifp pointer is stored in that
structure.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-16 14:40:43 +02:00
Philippe Guibert
ed78b7c825 zebra: add a helper structure to look zebra_pbr_ipset per ipsetname
Add an intermediate helper structure that is used to walk the list of
ipset entries, and look for associated name.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-16 14:40:43 +02:00
Philippe Guibert
7abd6c4fa0 zebra: add IPTABLE_ADD and IPTABLE_DEL commands in zapi
Those messages permit a remote daemon to configure an iptable entry. A
structure is defined that maps to an iptable entry. More specifically,
this structure proposes to associate fwmark, and a table ID.
Adding to the configuration, the initialisation of iptables hash list is
done into zebra netnamespace. Also a hook for notifying the sender that
the iptables has been correctly set is done.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-16 14:40:43 +02:00
Philippe Guibert
1907e4b80b zebra: pbr rule structure is being added fwmark tag
PBR rule is being added a 32 bit value that can be used to record a rule
in the kernel, by using a fwmark information.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-16 14:40:43 +02:00
Philippe Guibert
425bdd6bf1 zebra: handling notifications upon ipset creation/destruction done
Once ipset entries are injected in the kernel, the relevant daemon is
informed with a zebra message sent back.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-16 14:40:43 +02:00
Philippe Guibert
d59c13af5c lib: add ZEBRA IPSET defines
ZEBRA IPSET defines are added for creating/deleting ipset contexts.
Ans also create ipset hash sets.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-16 14:40:16 +02:00
Philippe Guibert
7661461a3a zebra: handle entry pointfs for ipset creation/destruction
IPset and IPset entries structures are introduced. Those entries reflect
the ipset structures and ipset hash sets that will be created on the
kernel.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-16 14:40:16 +02:00
Donald Sharp
d5c52f7605 zebra: When removing a rule, release from hash storing it.
When we are removing a rule from the zns->rules_hash, free up
the rule from the hash and free the memory.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-22 17:02:31 -04:00
Donald Sharp
8c3cd6c65c zebra: Allow rule replace semantics
When we get a rule that is supposed to replace
an existing rule, make it look like a rule replace
semantics.

Install new rule, then delete the old original rule.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-22 13:58:30 -04:00
Donald Sharp
e69aa08419 zebra: Allow for deletion of rules when the originator goes away
When zebra detects that the originator has dissapeared
delete all rules associated with that client.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-16 10:17:41 -04:00
Donald Sharp
b6c5d34354 lib, zebra: Add Rule insertion success/failure messages
Add code to allow rule insertion notifications to be
sent back up the stack.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:11:40 -05:00
Donald Sharp
a03219780f zebra: Make the ifp part of the rule structure
Every place we need to pass around the rule structure
we need to pass around the ifp as well.  Move it into
the structure.  This will also allow us to notify up
to higher level protocols that this worked properly
or not better too.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
Donald Sharp
43fe6a2a73 zebra: Keep track of rules written
Keep track of rules written into the kernel.  This will
allow us to delete them on shutdown if we are not cleaned
up properly.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
Donald Sharp
1fbfe5a572 zebra: Cleanup api
Allow the add/delete to go through a intermediary function in
zebra_pbr.c instead of directly to the underlying os call.  This
will allow future refinements to track the data a bit better
so that on shutdown we can delete the rules.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
Donald Sharp
fd71d73eb3 zebra: Cleanup a couple of api issues
1) use uint32_t instead of u_int32_t as we are supposed to
2) Consolidate priority into the rule.
3) Cleanup the api from this.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
vivek
942bf97b13 *: PBR - netlink interaction and basic definitions
Implement netlink interactions for Policy Based Routing. This includes
APIs to install and uninstall rules and handle notifications from the
kernel related to rule addition or deletion. Various definitions are
added to facilitate this.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00