Skip to contentSkip to conversation

ipv4: Remove flowi from struct rtable.

RFC PATCH New David Miller 1 participant 1 message Mar 3, 2011

Subsystems (4)
lore
Share & tools
lore

David Miller

author maintainer
#0 lore raw

RFC PATCH v3 5/8 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.

---
 include/net/route.h     |   24 +++++++-----
 net/ipv4/icmp.c         |    2 +-
 net/ipv4/ipmr.c         |   52 ++++++++++++++++++++-----
 net/ipv4/route.c        |   95 ++++++++++++++++++++++++++--------------------
 net/ipv4/xfrm4_policy.c |    7 +++-
 5 files changed, 116 insertions(+), 64 deletions(-)
include/net/route.h +14 -10
index ef85013..ebf50a9 100644
@@ -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 {
@@ -199,12 +203,12 @@ 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,
-				    .proto = rt->fl.proto,
+		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 };
 
net/ipv4/icmp.c +1 -1
index 994a785..1771ce6 100644
@@ -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);
net/ipv4/ipmr.c +41 -11

71 lines not on this page · raw message

net/ipv4/route.c +54 -41

222 lines not on this page · raw message

net/ipv4/xfrm4_policy.c +6 -1
index 45b8214..c70c42e 100644
@@ -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);
Signature · 1 line
1.7.4.1