Skip to content

Commit 6587005

Browse files
image-dragonopsiff
authored andcommitted
net: tunnel: make skb_vlan_inet_prepare() return drop reasons
[ Upstream commit 9990ddf ] Make skb_vlan_inet_prepare return the skb drop reasons, which is just what pskb_may_pull_reason() returns. Meanwhile, adjust all the call of it. Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit f478b8239d6564b20bbf2972e441c31f945a2b76) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent c26c787 commit 6587005

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

drivers/net/bareudp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,
319319
__be32 saddr;
320320
int err;
321321

322-
if (!skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB)))
322+
if (skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB)))
323323
return -EINVAL;
324324

325325
if (!sock)
@@ -385,7 +385,7 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
385385
__be16 sport;
386386
int err;
387387

388-
if (!skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB)))
388+
if (skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB)))
389389
return -EINVAL;
390390

391391
if (!sock)

drivers/net/geneve.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
927927
__be16 sport;
928928
int err;
929929

930-
if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
930+
if (skb_vlan_inet_prepare(skb, inner_proto_inherit))
931931
return -EINVAL;
932932

933933
sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);
@@ -1026,7 +1026,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
10261026
__be16 sport;
10271027
int err;
10281028

1029-
if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
1029+
if (skb_vlan_inet_prepare(skb, inner_proto_inherit))
10301030
return -EINVAL;
10311031

10321032
sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);

include/net/ip_tunnels.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,12 @@ static inline bool pskb_inet_may_pull(struct sk_buff *skb)
362362

363363
/* Variant of pskb_inet_may_pull().
364364
*/
365-
static inline bool skb_vlan_inet_prepare(struct sk_buff *skb,
366-
bool inner_proto_inherit)
365+
static inline enum skb_drop_reason
366+
skb_vlan_inet_prepare(struct sk_buff *skb, bool inner_proto_inherit)
367367
{
368368
int nhlen = 0, maclen = inner_proto_inherit ? 0 : ETH_HLEN;
369369
__be16 type = skb->protocol;
370+
enum skb_drop_reason reason;
370371

371372
/* Essentially this is skb_protocol(skb, true)
372373
* And we get MAC len.
@@ -387,11 +388,13 @@ static inline bool skb_vlan_inet_prepare(struct sk_buff *skb,
387388
/* For ETH_P_IPV6/ETH_P_IP we make sure to pull
388389
* a base network header in skb->head.
389390
*/
390-
if (!pskb_may_pull(skb, maclen + nhlen))
391-
return false;
391+
reason = pskb_may_pull_reason(skb, maclen + nhlen);
392+
if (reason)
393+
return reason;
392394

393395
skb_set_network_header(skb, maclen);
394-
return true;
396+
397+
return SKB_NOT_DROPPED_YET;
395398
}
396399

397400
static inline int ip_encap_hlen(struct ip_tunnel_encap *e)

0 commit comments

Comments
 (0)