Skip to content

Commit 4ce768a

Browse files
image-dragongregkh
authored andcommitted
net: tunnel: make skb_vlan_inet_prepare() return drop reasons
commit 9990ddf upstream. 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> Cc: Eric Dumazet <edumazet@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 88969c9 commit 4ce768a

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

drivers/net/bareudp.c

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

320-
if (!skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB)))
320+
if (skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB)))
321321
return -EINVAL;
322322

323323
if (!sock)
@@ -387,7 +387,7 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
387387
__be16 sport;
388388
int err;
389389

390-
if (!skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB)))
390+
if (skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB)))
391391
return -EINVAL;
392392

393393
if (!sock)

drivers/net/geneve.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
827827
__be16 sport;
828828
int err;
829829

830-
if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
830+
if (skb_vlan_inet_prepare(skb, inner_proto_inherit))
831831
return -EINVAL;
832832

833833
if (!gs4)
@@ -937,7 +937,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
937937
__be16 sport;
938938
int err;
939939

940-
if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
940+
if (skb_vlan_inet_prepare(skb, inner_proto_inherit))
941941
return -EINVAL;
942942

943943
if (!gs6)

drivers/net/vxlan/vxlan_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2381,7 +2381,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
23812381
__be32 vni = 0;
23822382

23832383
no_eth_encap = flags & VXLAN_F_GPE && skb->protocol != htons(ETH_P_TEB);
2384-
if (!skb_vlan_inet_prepare(skb, no_eth_encap))
2384+
if (skb_vlan_inet_prepare(skb, no_eth_encap))
23852385
goto drop;
23862386

23872387
old_iph = ip_hdr(skb);

include/net/ip_tunnels.h

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

468468
/* Variant of pskb_inet_may_pull().
469469
*/
470-
static inline bool skb_vlan_inet_prepare(struct sk_buff *skb,
471-
bool inner_proto_inherit)
470+
static inline enum skb_drop_reason
471+
skb_vlan_inet_prepare(struct sk_buff *skb, bool inner_proto_inherit)
472472
{
473473
int nhlen = 0, maclen = inner_proto_inherit ? 0 : ETH_HLEN;
474474
__be16 type = skb->protocol;
475+
enum skb_drop_reason reason;
475476

476477
/* Essentially this is skb_protocol(skb, true)
477478
* And we get MAC len.
@@ -492,11 +493,13 @@ static inline bool skb_vlan_inet_prepare(struct sk_buff *skb,
492493
/* For ETH_P_IPV6/ETH_P_IP we make sure to pull
493494
* a base network header in skb->head.
494495
*/
495-
if (!pskb_may_pull(skb, maclen + nhlen))
496-
return false;
496+
reason = pskb_may_pull_reason(skb, maclen + nhlen);
497+
if (reason)
498+
return reason;
497499

498500
skb_set_network_header(skb, maclen);
499-
return true;
501+
502+
return SKB_NOT_DROPPED_YET;
500503
}
501504

502505
static inline int ip_encap_hlen(struct ip_tunnel_encap *e)

0 commit comments

Comments
 (0)