Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e762a4a authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller
Browse files

[NET]: Introduce RTA_TABLE/FRA_TABLE attributes



Introduce RTA_TABLE route attribute and FRA_TABLE routing rule attribute
to hold 32 bit routing table IDs. Usespace compatibility is provided by
continuing to accept and send the rtm_table field, but because of its
limited size it can only carry the low 8 bits of the table ID. This
implies that if larger IDs are used, _all_ userspace programs using them
need to use RTA_TABLE.

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2dfe55b4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -36,6 +36,10 @@ enum
	FRA_UNUSED5,
	FRA_FWMARK,	/* netfilter mark (IPv4) */
	FRA_FLOW,	/* flow/class id */
	FRA_UNUSED6,
	FRA_UNUSED7,
	FRA_UNUSED8,
	FRA_TABLE,	/* Extended table id */
	__FRA_MAX
};

+8 −0
Original line number Diff line number Diff line
@@ -264,6 +264,7 @@ enum rtattr_type_t
	RTA_CACHEINFO,
	RTA_SESSION,
	RTA_MP_ALGO,
	RTA_TABLE,
	__RTA_MAX
};

@@ -717,6 +718,13 @@ extern void __rtnl_unlock(void);
	} \
} while(0)

static inline u32 rtm_get_table(struct rtattr **rta, u8 table)
{
	return RTA_GET_U32(rta[RTA_TABLE-1]);
rtattr_failure:
	return table;
}

#endif /* __KERNEL__ */


+7 −0
Original line number Diff line number Diff line
@@ -74,6 +74,13 @@ static inline void fib_rule_put(struct fib_rule *rule)
		call_rcu(&rule->rcu, fib_rule_put_rcu);
}

static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
{
	if (nla[FRA_TABLE])
		return nla_get_u32(nla[FRA_TABLE]);
	return frh->table;
}

extern int			fib_rules_register(struct fib_rules_ops *);
extern int			fib_rules_unregister(struct fib_rules_ops *);

+3 −2
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)

	rule->action = frh->action;
	rule->flags = frh->flags;
	rule->table = frh->table;
	rule->table = frh_get_table(frh, tb);

	if (!rule->pref && ops->default_pref)
		rule->pref = ops->default_pref();
@@ -245,7 +245,7 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
		if (frh->action && (frh->action != rule->action))
			continue;

		if (frh->table && (frh->table != rule->table))
		if (frh->table && (frh_get_table(frh, tb) != rule->table))
			continue;

		if (tb[FRA_PRIORITY] &&
@@ -291,6 +291,7 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule,

	frh = nlmsg_data(nlh);
	frh->table = rule->table;
	NLA_PUT_U32(skb, FRA_TABLE, rule->table);
	frh->res1 = 0;
	frh->res2 = 0;
	frh->action = rule->action;
+4 −3
Original line number Diff line number Diff line
@@ -491,7 +491,8 @@ static int dn_fib_check_attr(struct rtmsg *r, struct rtattr **rta)
		if (attr) {
			if (RTA_PAYLOAD(attr) < 4 && RTA_PAYLOAD(attr) != 2)
				return -EINVAL;
			if (i != RTA_MULTIPATH && i != RTA_METRICS)
			if (i != RTA_MULTIPATH && i != RTA_METRICS &&
			    i != RTA_TABLE)
				rta[i-1] = (struct rtattr *)RTA_DATA(attr);
		}
	}
@@ -508,7 +509,7 @@ int dn_fib_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
	if (dn_fib_check_attr(r, rta))
		return -EINVAL;

	tb = dn_fib_get_table(r->rtm_table, 0);
	tb = dn_fib_get_table(rtm_get_table(rta, r->rtm_table), 0);
	if (tb)
		return tb->delete(tb, r, (struct dn_kern_rta *)rta, nlh, &NETLINK_CB(skb));

@@ -524,7 +525,7 @@ int dn_fib_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
	if (dn_fib_check_attr(r, rta))
		return -EINVAL;

	tb = dn_fib_get_table(r->rtm_table, 1);
	tb = dn_fib_get_table(rtm_get_table(rta, r->rtm_table), 1);
	if (tb) 
		return tb->insert(tb, r, (struct dn_kern_rta *)rta, nlh, &NETLINK_CB(skb));

Loading