summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--zebra/rule_netlink.c70
-rw-r--r--zebra/rule_netlink.h2
-rw-r--r--zebra/zebra_pbr.c5
-rw-r--r--zebra/zebra_pbr.h19
-rw-r--r--zebra/zserv.c5
5 files changed, 45 insertions, 56 deletions
diff --git a/zebra/rule_netlink.c b/zebra/rule_netlink.c
index 4b8791ee2..3228d0e4b 100644
--- a/zebra/rule_netlink.c
+++ b/zebra/rule_netlink.c
@@ -52,7 +52,7 @@
* waiting for netlink status.
*/
static int netlink_rule_update(int cmd, struct zebra_pbr_rule *rule,
- struct interface *ifp, u_int32_t rule_pri)
+ struct interface *ifp)
{
int family;
int bytelen;
@@ -66,7 +66,7 @@ static int netlink_rule_update(int cmd, struct zebra_pbr_rule *rule,
char buf1[PREFIX_STRLEN];
char buf2[PREFIX_STRLEN];
- memset(&req, 0, sizeof req - NL_PKT_BUF_SIZE);
+ memset(&req, 0, sizeof(req) - NL_PKT_BUF_SIZE);
family = PREFIX_FAMILY(&rule->filter.src_ip);
bytelen = (family == AF_INET ? 4 : 16);
@@ -82,7 +82,7 @@ static int netlink_rule_update(int cmd, struct zebra_pbr_rule *rule,
req.n.nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL;
/* rule's pref # */
- addattr32(&req.n, sizeof(req), FRA_PRIORITY, rule_pri);
+ addattr32(&req.n, sizeof(req), FRA_PRIORITY, rule->priority);
/* interface on which applied */
addattr_l(&req.n, sizeof(req), FRA_IFNAME, ifp->name,
@@ -111,14 +111,13 @@ static int netlink_rule_update(int cmd, struct zebra_pbr_rule *rule,
}
if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug("Tx %s family %s IF %s(%u) Pref %u Src %s "
- "Dst %s Table %u",
- nl_msg_type_to_str(cmd),
- nl_family_to_str(family),
- ifp->name, ifp->ifindex, rule_pri,
- prefix2str(&rule->filter.src_ip, buf1, sizeof(buf1)),
- prefix2str(&rule->filter.dst_ip, buf2, sizeof(buf2)),
- rule->action.table);
+ zlog_debug(
+ "Tx %s family %s IF %s(%u) Pref %u Src %s Dst %s Table %u",
+ nl_msg_type_to_str(cmd), nl_family_to_str(family),
+ ifp->name, ifp->ifindex, rule->priority,
+ prefix2str(&rule->filter.src_ip, buf1, sizeof(buf1)),
+ prefix2str(&rule->filter.dst_ip, buf2, sizeof(buf2)),
+ rule->action.table);
/* Ship off the message.
* Note: Currently, netlink_talk() is a blocking call which returns
@@ -137,31 +136,27 @@ static int netlink_rule_update(int cmd, struct zebra_pbr_rule *rule,
* goes in the rule to denote relative ordering; it may or may not be the
* same as the rule's user-defined sequence number.
*/
-void kernel_add_pbr_rule(struct zebra_pbr_rule *rule,
- struct interface *ifp, u_int32_t rule_pri)
+void kernel_add_pbr_rule(struct zebra_pbr_rule *rule, struct interface *ifp)
{
int ret = 0;
- ret = netlink_rule_update(RTM_NEWRULE, rule, ifp, rule_pri);
- kernel_pbr_rule_add_del_status(rule, ifp, rule_pri,
- (!ret) ?
- SOUTHBOUND_INSTALL_SUCCESS :
- SOUTHBOUND_INSTALL_FAILURE);
+ ret = netlink_rule_update(RTM_NEWRULE, rule, ifp);
+ kernel_pbr_rule_add_del_status(rule, ifp,
+ (!ret) ? SOUTHBOUND_INSTALL_SUCCESS
+ : SOUTHBOUND_INSTALL_FAILURE);
}
/*
* Uninstall specified rule for a specific interface.
*/
-void kernel_del_pbr_rule(struct zebra_pbr_rule *rule,
- struct interface *ifp, u_int32_t rule_pri)
+void kernel_del_pbr_rule(struct zebra_pbr_rule *rule, struct interface *ifp)
{
int ret = 0;
- ret = netlink_rule_update(RTM_DELRULE, rule, ifp, rule_pri);
- kernel_pbr_rule_add_del_status(rule, ifp, rule_pri,
- (!ret) ?
- SOUTHBOUND_DELETE_SUCCESS :
- SOUTHBOUND_DELETE_FAILURE);
+ ret = netlink_rule_update(RTM_DELRULE, rule, ifp);
+ kernel_pbr_rule_add_del_status(rule, ifp,
+ (!ret) ? SOUTHBOUND_DELETE_SUCCESS
+ : SOUTHBOUND_DELETE_FAILURE);
}
/*
@@ -180,7 +175,6 @@ int netlink_rule_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
int len;
char *ifname;
struct interface *ifp;
- u_int32_t rule_pri = 0;
struct zebra_pbr_rule rule;
char buf1[PREFIX_STRLEN];
char buf2[PREFIX_STRLEN];
@@ -219,7 +213,7 @@ int netlink_rule_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
memset(&rule, 0, sizeof(rule));
if (tb[FRA_PRIORITY])
- rule_pri = *(u_int32_t *)RTA_DATA(tb[FRA_PRIORITY]);
+ rule.priority = *(uint32_t *)RTA_DATA(tb[FRA_PRIORITY]);
if (tb[FRA_SRC]) {
if (frh->family == AF_INET)
@@ -244,21 +238,21 @@ int netlink_rule_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
}
if (tb[FRA_TABLE])
- rule.action.table = *(u_int32_t *)RTA_DATA(tb[FRA_TABLE]);
+ rule.action.table = *(uint32_t *)RTA_DATA(tb[FRA_TABLE]);
else
rule.action.table = frh->table;
if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug("Rx %s family %s IF %s(%u) Pref %u Src %s "
- "Dst %s Table %u",
- nl_msg_type_to_str(h->nlmsg_type),
- nl_family_to_str(frh->family),
- ifp->name, ifp->ifindex, rule_pri,
- prefix2str(&rule.filter.src_ip, buf1, sizeof(buf1)),
- prefix2str(&rule.filter.dst_ip, buf2, sizeof(buf2)),
- rule.action.table);
-
- return kernel_pbr_rule_del(&rule, ifp, rule_pri);
+ zlog_debug(
+ "Rx %s family %s IF %s(%u) Pref %u Src %s Dst %s Table %u",
+ nl_msg_type_to_str(h->nlmsg_type),
+ nl_family_to_str(frh->family), ifp->name, ifp->ifindex,
+ rule.priority,
+ prefix2str(&rule.filter.src_ip, buf1, sizeof(buf1)),
+ prefix2str(&rule.filter.dst_ip, buf2, sizeof(buf2)),
+ rule.action.table);
+
+ return kernel_pbr_rule_del(&rule, ifp);
}
/*
diff --git a/zebra/rule_netlink.h b/zebra/rule_netlink.h
index 034068b89..3a9b51309 100644
--- a/zebra/rule_netlink.h
+++ b/zebra/rule_netlink.h
@@ -1,4 +1,4 @@
-/*
+/*
* Zebra Policy Based Routing (PBR) interaction with the kernel using
* netlink - public definitions and function declarations.
* Copyright (C) 2018 Cumulus Networks, Inc.
diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c
index 6e521be39..827005b3a 100644
--- a/zebra/zebra_pbr.c
+++ b/zebra/zebra_pbr.c
@@ -36,7 +36,6 @@
*/
void kernel_pbr_rule_add_del_status(struct zebra_pbr_rule *rule,
struct interface *ifp,
- u_int32_t rule_pri,
enum southbound_results res)
{
}
@@ -44,9 +43,7 @@ void kernel_pbr_rule_add_del_status(struct zebra_pbr_rule *rule,
/*
* Handle rule delete notification from kernel.
*/
-int kernel_pbr_rule_del(struct zebra_pbr_rule *rule,
- struct interface *ifp,
- u_int32_t rule_pri)
+int kernel_pbr_rule_del(struct zebra_pbr_rule *rule, struct interface *ifp)
{
return 0;
}
diff --git a/zebra/zebra_pbr.h b/zebra/zebra_pbr.h
index 2e80aeb8a..b87388afc 100644
--- a/zebra/zebra_pbr.h
+++ b/zebra/zebra_pbr.h
@@ -39,7 +39,7 @@
* specified.
*/
struct zebra_pbr_filter {
- u_int32_t filter_bm;
+ uint32_t filter_bm;
#define PBR_FILTER_SRC_IP (1 << 0)
#define PBR_FILTER_DST_IP (1 << 1)
#define PBR_FILTER_SRC_PORT (1 << 2)
@@ -50,8 +50,8 @@ struct zebra_pbr_filter {
struct prefix dst_ip;
/* Source and Destination higher-layer (TCP/UDP) port numbers. */
- u_int16_t src_port;
- u_int16_t dst_port;
+ uint16_t src_port;
+ uint16_t dst_port;
};
#define IS_RULE_FILTERING_ON_SRC_IP(r) \
@@ -73,7 +73,7 @@ struct zebra_pbr_filter {
* the user criteria may directly point to a table too.
*/
struct zebra_pbr_action {
- u_int32_t table;
+ uint32_t table;
};
/*
@@ -84,7 +84,8 @@ struct zebra_pbr_action {
* order amongst rules.
*/
struct zebra_pbr_rule {
- u_int32_t seq;
+ uint32_t seq;
+ uint32_t priority;
struct zebra_pbr_filter filter;
struct zebra_pbr_action action;
};
@@ -97,13 +98,13 @@ struct zebra_pbr_rule {
* rule priority - maps to preference/FRA_PRIORITY on Linux.
*/
extern void kernel_add_pbr_rule(struct zebra_pbr_rule *rule,
- struct interface *ifp, u_int32_t rule_pri);
+ struct interface *ifp);
/*
* Uninstall specified rule for a specific interface.
*/
extern void kernel_del_pbr_rule(struct zebra_pbr_rule *rule,
- struct interface *ifp, u_int32_t rule_pri);
+ struct interface *ifp);
/*
* Get to know existing PBR rules in the kernel - typically called at startup.
@@ -115,14 +116,12 @@ extern void kernel_read_pbr_rules(struct zebra_ns *zns);
*/
extern void kernel_pbr_rule_add_del_status(struct zebra_pbr_rule *rule,
struct interface *ifp,
- u_int32_t rule_pri,
enum southbound_results res);
/*
* Handle rule delete notification from kernel.
*/
extern int kernel_pbr_rule_del(struct zebra_pbr_rule *rule,
- struct interface *ifp,
- u_int32_t rule_pri);
+ struct interface *ifp);
#endif /* _ZEBRA_PBR_H */
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 13936e536..007a02ced 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -2595,7 +2595,6 @@ static inline void zread_rule(uint16_t command, struct zserv *client,
struct interface *ifp;
struct stream *s;
uint32_t total, i;
- uint32_t priority;
ifindex_t ifindex;
s = client->ibuf;
@@ -2605,7 +2604,7 @@ static inline void zread_rule(uint16_t command, struct zserv *client,
memset(&zpr, 0, sizeof(zpr));
STREAM_GETL(s, zpr.seq);
- STREAM_GETL(s, priority);
+ STREAM_GETL(s, zpr.priority);
STREAM_GETC(s, zpr.filter.src_ip.family);
STREAM_GETC(s, zpr.filter.src_ip.prefixlen);
STREAM_GET(&zpr.filter.src_ip.u.prefix, s,
@@ -2637,7 +2636,7 @@ static inline void zread_rule(uint16_t command, struct zserv *client,
if (zpr.filter.dst_port)
zpr.filter.filter_bm |= PBR_FILTER_DST_PORT;
- kernel_add_pbr_rule(&zpr, ifp, priority);
+ kernel_add_pbr_rule(&zpr, ifp);
}
stream_failure: