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

Commit 61adedf3 authored by Jiri Benc's avatar Jiri Benc Committed by David S. Miller
Browse files

route: move lwtunnel state to dst_entry



Currently, the lwtunnel state resides in per-protocol data. This is
a problem if we encapsulate ipv6 traffic in an ipv4 tunnel (or vice versa).
The xmit function of the tunnel does not know whether the packet has been
routed to it by ipv4 or ipv6, yet it needs the lwtstate data. Moving the
lwtstate data to dst_entry makes such inter-protocol tunneling possible.

As a bonus, this brings a nice diffstat.

Signed-off-by: default avatarJiri Benc <jbenc@redhat.com>
Acked-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
Acked-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7c383fb2
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -295,7 +295,6 @@ static struct rtable *vrf_rtable_create(struct net_device *dev)
		rth->rt_uses_gateway = 0;
		INIT_LIST_HEAD(&rth->rt_uncached);
		rth->rt_uncached_list = NULL;
		rth->rt_lwtstate = NULL;
	}

	return rth;
+2 −2
Original line number Diff line number Diff line
@@ -1909,7 +1909,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
	u32 flags = vxlan->flags;

	/* FIXME: Support IPv6 */
	info = skb_tunnel_info(skb, AF_INET);
	info = skb_tunnel_info(skb);

	if (rdst) {
		dst_port = rdst->remote_port ? rdst->remote_port : vxlan->cfg.dst_port;
@@ -2105,7 +2105,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
	struct vxlan_fdb *f;

	/* FIXME: Support IPv6 */
	info = skb_tunnel_info(skb, AF_INET);
	info = skb_tunnel_info(skb);

	skb_reset_mac_header(skb);
	eth = eth_hdr(skb);
+2 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ struct dst_entry {
#else
	void			*__pad1;
#endif
	struct lwtunnel_state   *lwtstate;
	int			(*input)(struct sk_buff *);
	int			(*output)(struct sock *sk, struct sk_buff *skb);

@@ -89,7 +90,7 @@ struct dst_entry {
	 * (L1_CACHE_SIZE would be too much)
	 */
#ifdef CONFIG_64BIT
	long			__pad_to_align_refcnt[2];
	long			__pad_to_align_refcnt[1];
#endif
	/*
	 * __refcnt wants to be on a different cache line from
+5 −10
Original line number Diff line number Diff line
@@ -23,22 +23,17 @@ static inline struct metadata_dst *skb_metadata_dst(struct sk_buff *skb)
	return NULL;
}

static inline struct ip_tunnel_info *skb_tunnel_info(struct sk_buff *skb,
						     int family)
static inline struct ip_tunnel_info *skb_tunnel_info(struct sk_buff *skb)
{
	struct metadata_dst *md_dst = skb_metadata_dst(skb);
	struct rtable *rt;
	struct dst_entry *dst;

	if (md_dst)
		return &md_dst->u.tun_info;

	switch (family) {
	case AF_INET:
		rt = (struct rtable *)skb_dst(skb);
		if (rt && rt->rt_lwtstate)
			return lwt_tun_info(rt->rt_lwtstate);
		break;
	}
	dst = skb_dst(skb);
	if (dst && dst->lwtstate)
		return lwt_tun_info(dst->lwtstate);

	return NULL;
}
+0 −1
Original line number Diff line number Diff line
@@ -133,7 +133,6 @@ struct rt6_info {
	/* more non-fragment space at head required */
	unsigned short			rt6i_nfheader_len;
	u8				rt6i_protocol;
	struct lwtunnel_state		*rt6i_lwtstate;
};

static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst)
Loading