Commit 5e2b61f7 authored by David S. Miller's avatar David S. Miller

ipv4: Remove flowi from struct rtable.

The only necessary parts are the src/dst addresses, the
interface indexes, the TOS, and the mark.

The rest is unnecessary bloat, which amounts to nearly
50 bytes on 64-bit.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1018b5c0
......@@ -53,16 +53,20 @@ struct fib_info;
struct rtable {
struct dst_entry dst;
/* Cache lookup keys */
struct flowi fl;
/* Lookup key. */
__be32 rt_key_dst;
__be32 rt_key_src;
int rt_genid;
unsigned rt_flags;
__u16 rt_type;
__u8 rt_tos;
__be32 rt_dst; /* Path destination */
__be32 rt_src; /* Path source */
int rt_iif;
int rt_oif;
__u32 rt_mark;
/* Info on neighbour */
__be32 rt_gateway;
......@@ -76,12 +80,12 @@ struct rtable {
static inline bool rt_is_input_route(struct rtable *rt)
{
return rt->fl.iif != 0;
return rt->rt_iif != 0;
}
static inline bool rt_is_output_route(struct rtable *rt)
{
return rt->fl.iif == 0;
return rt->rt_iif == 0;
}
struct ip_rt_acct {
......@@ -212,11 +216,11 @@ static inline struct rtable *ip_route_newports(struct rtable *rt,
__be16 dport, struct sock *sk)
{
if (sport != orig_sport || dport != orig_dport) {
struct flowi fl = { .oif = rt->fl.oif,
.mark = rt->fl.mark,
.fl4_dst = rt->fl.fl4_dst,
.fl4_src = rt->fl.fl4_src,
.fl4_tos = rt->fl.fl4_tos,
struct flowi fl = { .oif = rt->rt_oif,
.mark = rt->rt_mark,
.fl4_dst = rt->rt_key_dst,
.fl4_src = rt->rt_key_src,
.fl4_tos = rt->rt_tos,
.proto = protocol,
.fl_ip_sport = sport,
.fl_ip_dport = dport };
......
......@@ -563,7 +563,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
rcu_read_lock();
if (rt_is_input_route(rt) &&
net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr)
dev = dev_get_by_index_rcu(net, rt->fl.iif);
dev = dev_get_by_index_rcu(net, rt->rt_iif);
if (dev)
saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK);
......
......@@ -1813,12 +1813,22 @@ int ip_mr_input(struct sk_buff *skb)
if (IPCB(skb)->flags & IPSKB_FORWARDED)
goto dont_forward;
err = ipmr_fib_lookup(net, &skb_rtable(skb)->fl, &mrt);
if (err < 0) {
kfree_skb(skb);
return err;
{
struct rtable *rt = skb_rtable(skb);
struct flowi fl = {
.fl4_dst = rt->rt_key_dst,
.fl4_src = rt->rt_key_src,
.fl4_tos = rt->rt_tos,
.oif = rt->rt_oif,
.iif = rt->rt_iif,
.mark = rt->rt_mark,
};
err = ipmr_fib_lookup(net, &fl, &mrt);
if (err < 0) {
kfree_skb(skb);
return err;
}
}
if (!local) {
if (IPCB(skb)->opt.router_alert) {
if (ip_call_ra_chain(skb))
......@@ -1946,9 +1956,19 @@ int pim_rcv_v1(struct sk_buff *skb)
pim = igmp_hdr(skb);
if (ipmr_fib_lookup(net, &skb_rtable(skb)->fl, &mrt) < 0)
goto drop;
{
struct rtable *rt = skb_rtable(skb);
struct flowi fl = {
.fl4_dst = rt->rt_key_dst,
.fl4_src = rt->rt_key_src,
.fl4_tos = rt->rt_tos,
.oif = rt->rt_oif,
.iif = rt->rt_iif,
.mark = rt->rt_mark,
};
if (ipmr_fib_lookup(net, &fl, &mrt) < 0)
goto drop;
}
if (!mrt->mroute_do_pim ||
pim->group != PIM_V1_VERSION || pim->code != PIM_V1_REGISTER)
goto drop;
......@@ -1978,9 +1998,19 @@ static int pim_rcv(struct sk_buff *skb)
csum_fold(skb_checksum(skb, 0, skb->len, 0))))
goto drop;
if (ipmr_fib_lookup(net, &skb_rtable(skb)->fl, &mrt) < 0)
goto drop;
{
struct rtable *rt = skb_rtable(skb);
struct flowi fl = {
.fl4_dst = rt->rt_key_dst,
.fl4_src = rt->rt_key_src,
.fl4_tos = rt->rt_tos,
.oif = rt->rt_oif,
.iif = rt->rt_iif,
.mark = rt->rt_mark,
};
if (ipmr_fib_lookup(net, &fl, &mrt) < 0)
goto drop;
}
if (__pim_rcv(mrt, skb, sizeof(*pim))) {
drop:
kfree_skb(skb);
......
This diff is collapsed.
......@@ -70,7 +70,12 @@ static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
{
struct rtable *rt = (struct rtable *)xdst->route;
xdst->u.rt.fl = *fl;
rt->rt_key_dst = fl->fl4_dst;
rt->rt_key_src = fl->fl4_src;
rt->rt_tos = fl->fl4_tos;
rt->rt_iif = fl->iif;
rt->rt_oif = fl->oif;
rt->rt_mark = fl->mark;
xdst->u.dst.dev = dev;
dev_hold(dev);
......
......@@ -143,7 +143,7 @@ static int route4_classify(struct sk_buff *skb, struct tcf_proto *tp,
if (head == NULL)
goto old_method;
iif = ((struct rtable *)dst)->fl.iif;
iif = ((struct rtable *)dst)->rt_iif;
h = route4_fastmap_hash(id, iif);
if (id == head->fastmap[h].id &&
......
......@@ -264,7 +264,7 @@ META_COLLECTOR(int_rtiif)
if (unlikely(skb_rtable(skb) == NULL))
*err = -1;
else
dst->value = skb_rtable(skb)->fl.iif;
dst->value = skb_rtable(skb)->rt_iif;
}
/**************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment