summaryrefslogtreecommitdiff
path: root/zebra/rule_netlink.c
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2019-10-15 15:39:49 -0400
committerStephen Worley <sworley@cumulusnetworks.com>2019-10-15 15:39:49 -0400
commitb19d55d048f6a644629595da361df9e6d0674555 (patch)
treeea01d5d386e823009c18f2f4873ba8bd976fb54b /zebra/rule_netlink.c
parentb77a69bdc601133612d89cb5e389f014d3e68970 (diff)
zebra: Don't bother ref'ing ifp in zebra_pbr_rule
If we only really use the ifp for the name, then don't bother referencing the ifp. If that ifp is freed, we don't expect zebra to handle the rules that use it (that's pbrd's job), so it is going to be pointing to unintialized memory when we decide to remove that rule later. Thus, just keep the name in the data and dont mess with pointer refs. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'zebra/rule_netlink.c')
-rw-r--r--zebra/rule_netlink.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/zebra/rule_netlink.c b/zebra/rule_netlink.c
index 1b465b0335..2fdb215128 100644
--- a/zebra/rule_netlink.c
+++ b/zebra/rule_netlink.c
@@ -86,9 +86,8 @@ static int netlink_rule_update(int cmd, struct zebra_pbr_rule *rule)
addattr32(&req.n, sizeof(req), FRA_PRIORITY, rule->rule.priority);
/* interface on which applied */
- if (rule->ifp)
- addattr_l(&req.n, sizeof(req), FRA_IFNAME, rule->ifp->name,
- strlen(rule->ifp->name) + 1);
+ addattr_l(&req.n, sizeof(req), FRA_IFNAME, rule->ifname,
+ strlen(rule->ifname) + 1);
/* source IP, if specified */
if (IS_RULE_FILTERING_ON_SRC_IP(rule)) {
@@ -122,8 +121,7 @@ static int netlink_rule_update(int cmd, struct zebra_pbr_rule *rule)
zlog_debug(
"Tx %s family %s IF %s(%u) Pref %u Fwmark %u Src %s Dst %s Table %u",
nl_msg_type_to_str(cmd), nl_family_to_str(family),
- rule->ifp ? rule->ifp->name : "Unknown",
- rule->rule.ifindex, rule->rule.priority,
+ rule->ifname, rule->rule.ifindex, rule->rule.priority,
rule->rule.filter.fwmark,
prefix2str(&rule->rule.filter.src_ip, buf1,
sizeof(buf1)),
@@ -227,13 +225,15 @@ int netlink_rule_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
if (tb[FRA_IFNAME] == NULL)
return 0;
- /* If we don't know the interface, we don't care. */
ifname = (char *)RTA_DATA(tb[FRA_IFNAME]);
zns = zebra_ns_lookup(ns_id);
- rule.ifp = if_lookup_by_name_per_ns(zns, ifname);
- if (!rule.ifp)
+
+ /* If we don't know the interface, we don't care. */
+ if (!if_lookup_by_name_per_ns(zns, ifname))
return 0;
+ strlcpy(rule.ifname, ifname, sizeof(rule.ifname));
+
if (tb[FRA_PRIORITY])
rule.rule.priority = *(uint32_t *)RTA_DATA(tb[FRA_PRIORITY]);
@@ -268,8 +268,8 @@ int netlink_rule_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
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), rule.ifp->name,
- rule.ifp->ifindex, rule.rule.priority,
+ nl_family_to_str(frh->family), rule.ifname,
+ rule.rule.ifindex, rule.rule.priority,
prefix2str(&rule.rule.filter.src_ip, buf1,
sizeof(buf1)),
prefix2str(&rule.rule.filter.dst_ip, buf2,