Skip to content

Commit

Permalink
lwtunnel: set skb protocol and dev
Browse files Browse the repository at this point in the history
In the locally-generated packet path skb->protocol may not be set and
this is required for the lwtunnel encap in order to get the lwtstate.

This would otherwise have been set by ip_output or ip6_output so set
skb->protocol prior to calling the lwtunnel encap
function. Additionally set skb->dev in case it is needed further down
the transmit path.

Signed-off-by: Robert Shearman <rshearma@brocade.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Robert Shearman authored and David S. Miller committed Aug 4, 2015
1 parent 58da018 commit abf7c1c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions net/core/lwtunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,12 @@ int lwtunnel_output6(struct sock *sk, struct sk_buff *skb)
struct rt6_info *rt = (struct rt6_info *)skb_dst(skb);
struct lwtunnel_state *lwtstate = NULL;

if (rt)
if (rt) {
lwtstate = rt->rt6i_lwtstate;
skb->dev = rt->dst.dev;
}

skb->protocol = htons(ETH_P_IPV6);

return __lwtunnel_output(sk, skb, lwtstate);
}
Expand All @@ -227,8 +231,12 @@ int lwtunnel_output(struct sock *sk, struct sk_buff *skb)
struct rtable *rt = (struct rtable *)skb_dst(skb);
struct lwtunnel_state *lwtstate = NULL;

if (rt)
if (rt) {
lwtstate = rt->rt_lwtstate;
skb->dev = rt->dst.dev;
}

skb->protocol = htons(ETH_P_IP);

return __lwtunnel_output(sk, skb, lwtstate);
}
Expand Down

0 comments on commit abf7c1c

Please sign in to comment.