Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 34459
b: refs/heads/master
c: 9e762a4
h: refs/heads/master
i:
  34457: e76c3e1
  34455: 1923485
v: v3
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Sep 22, 2006
1 parent 2da245b commit d8c214a
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2dfe55b47e3d66ded5a84caf71e0da5710edf48b
refs/heads/master: 9e762a4a89b302cb3b26a1f9bb33eff459eaeca9
4 changes: 4 additions & 0 deletions trunk/include/linux/fib_rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
8 changes: 8 additions & 0 deletions trunk/include/linux/rtnetlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ enum rtattr_type_t
RTA_CACHEINFO,
RTA_SESSION,
RTA_MP_ALGO,
RTA_TABLE,
__RTA_MAX
};

Expand Down Expand Up @@ -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__ */


Expand Down
7 changes: 7 additions & 0 deletions trunk/include/net/fib_rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);

Expand Down
5 changes: 3 additions & 2 deletions trunk/net/core/fib_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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] &&
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions trunk/net/decnet/dn_fib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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));

Expand All @@ -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));

Expand Down
1 change: 1 addition & 0 deletions trunk/net/decnet/dn_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,7 @@ static int dn_rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
r->rtm_src_len = 0;
r->rtm_tos = 0;
r->rtm_table = RT_TABLE_MAIN;
RTA_PUT_U32(skb, RTA_TABLE, RT_TABLE_MAIN);
r->rtm_type = rt->rt_type;
r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED;
r->rtm_scope = RT_SCOPE_UNIVERSE;
Expand Down
1 change: 1 addition & 0 deletions trunk/net/decnet/dn_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ static int dn_fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
rtm->rtm_src_len = 0;
rtm->rtm_tos = 0;
rtm->rtm_table = tb_id;
RTA_PUT_U32(skb, RTA_TABLE, tb_id);
rtm->rtm_flags = fi->fib_flags;
rtm->rtm_scope = scope;
rtm->rtm_type = type;
Expand Down
7 changes: 4 additions & 3 deletions trunk/net/ipv4/fib_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ static int inet_check_attr(struct rtmsg *r, struct rtattr **rta)
if (attr) {
if (RTA_PAYLOAD(attr) < 4)
return -EINVAL;
if (i != RTA_MULTIPATH && i != RTA_METRICS)
if (i != RTA_MULTIPATH && i != RTA_METRICS &&
i != RTA_TABLE)
*rta = (struct rtattr*)RTA_DATA(attr);
}
}
Expand All @@ -310,7 +311,7 @@ int inet_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
if (inet_check_attr(r, rta))
return -EINVAL;

tb = fib_get_table(r->rtm_table);
tb = fib_get_table(rtm_get_table(rta, r->rtm_table));
if (tb)
return tb->tb_delete(tb, r, (struct kern_rta*)rta, nlh, &NETLINK_CB(skb));
return -ESRCH;
Expand All @@ -325,7 +326,7 @@ int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
if (inet_check_attr(r, rta))
return -EINVAL;

tb = fib_new_table(r->rtm_table);
tb = fib_new_table(rtm_get_table(rta, r->rtm_table));
if (tb)
return tb->tb_insert(tb, r, (struct kern_rta*)rta, nlh, &NETLINK_CB(skb));
return -ENOBUFS;
Expand Down
1 change: 1 addition & 0 deletions trunk/net/ipv4/fib_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ static struct nla_policy fib4_rule_policy[FRA_MAX+1] __read_mostly = {
[FRA_DST] = { .type = NLA_U32 },
[FRA_FWMARK] = { .type = NLA_U32 },
[FRA_FLOW] = { .type = NLA_U32 },
[FRA_TABLE] = { .type = NLA_U32 },
};

static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
Expand Down
1 change: 1 addition & 0 deletions trunk/net/ipv4/fib_semantics.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
rtm->rtm_src_len = 0;
rtm->rtm_tos = tos;
rtm->rtm_table = tb_id;
RTA_PUT_U32(skb, RTA_TABLE, tb_id);
rtm->rtm_type = type;
rtm->rtm_flags = fi->fib_flags;
rtm->rtm_scope = scope;
Expand Down
1 change: 1 addition & 0 deletions trunk/net/ipv4/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -2652,6 +2652,7 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
r->rtm_src_len = 0;
r->rtm_tos = rt->fl.fl4_tos;
r->rtm_table = RT_TABLE_MAIN;
RTA_PUT_U32(skb, RTA_TABLE, RT_TABLE_MAIN);
r->rtm_type = rt->rt_type;
r->rtm_scope = RT_SCOPE_UNIVERSE;
r->rtm_protocol = RTPROT_UNSPEC;
Expand Down
1 change: 1 addition & 0 deletions trunk/net/ipv6/fib6_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ static struct nla_policy fib6_rule_policy[RTA_MAX+1] __read_mostly = {
[FRA_PRIORITY] = { .type = NLA_U32 },
[FRA_SRC] = { .minlen = sizeof(struct in6_addr) },
[FRA_DST] = { .minlen = sizeof(struct in6_addr) },
[FRA_TABLE] = { .type = NLA_U32 },
};

static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
Expand Down
13 changes: 9 additions & 4 deletions trunk/net/ipv6/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,8 @@ int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)

if (inet6_rtm_to_rtmsg(r, arg, &rtmsg))
return -EINVAL;
return ip6_route_del(&rtmsg, nlh, arg, &NETLINK_CB(skb), r->rtm_table);
return ip6_route_del(&rtmsg, nlh, arg, &NETLINK_CB(skb),
rtm_get_table(arg, r->rtm_table));
}

int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
Expand All @@ -1869,7 +1870,8 @@ int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)

if (inet6_rtm_to_rtmsg(r, arg, &rtmsg))
return -EINVAL;
return ip6_route_add(&rtmsg, nlh, arg, &NETLINK_CB(skb), r->rtm_table);
return ip6_route_add(&rtmsg, nlh, arg, &NETLINK_CB(skb),
rtm_get_table(arg, r->rtm_table));
}

struct rt6_rtnl_dump_arg
Expand All @@ -1887,6 +1889,7 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
struct nlmsghdr *nlh;
unsigned char *b = skb->tail;
struct rta_cacheinfo ci;
u32 table;

if (prefix) { /* user wants prefix routes only */
if (!(rt->rt6i_flags & RTF_PREFIX_RT)) {
Expand All @@ -1902,9 +1905,11 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
rtm->rtm_src_len = rt->rt6i_src.plen;
rtm->rtm_tos = 0;
if (rt->rt6i_table)
rtm->rtm_table = rt->rt6i_table->tb6_id;
table = rt->rt6i_table->tb6_id;
else
rtm->rtm_table = RT6_TABLE_UNSPEC;
table = RT6_TABLE_UNSPEC;
rtm->rtm_table = table;
RTA_PUT_U32(skb, RTA_TABLE, table);
if (rt->rt6i_flags&RTF_REJECT)
rtm->rtm_type = RTN_UNREACHABLE;
else if (rt->rt6i_dev && (rt->rt6i_dev->flags&IFF_LOOPBACK))
Expand Down

0 comments on commit d8c214a

Please sign in to comment.