lkml.org 
[lkml]   [2022]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2 net-next 4/8] net: ipv4: use kfree_skb_reason() in ip_rcv_core()
From
On 1/27/22 2:13 AM, menglong8.dong@gmail.com wrote:
> diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
> index 3a025c011971..7f64c5432cba 100644
> --- a/net/ipv4/ip_input.c
> +++ b/net/ipv4/ip_input.c
> @@ -436,13 +436,18 @@ static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
> static struct sk_buff *ip_rcv_core(struct sk_buff *skb, struct net *net)
> {
> const struct iphdr *iph;
> + int drop_reason;
> u32 len;
>
> + drop_reason = SKB_DROP_REASON_NOT_SPECIFIED;
> +
> /* When the interface is in promisc. mode, drop all the crap
> * that it receives, do not try to analyse it.
> */
> - if (skb->pkt_type == PACKET_OTHERHOST)
> + if (skb->pkt_type == PACKET_OTHERHOST) {
> + drop_reason = SKB_DROP_REASON_OTHERHOST;
> goto drop;
> + }
>
> __IP_UPD_PO_STATS(net, IPSTATS_MIB_IN, skb->len);
>
> @@ -516,11 +521,13 @@ static struct sk_buff *ip_rcv_core(struct sk_buff *skb, struct net *net)

There's another path:
len = ntohs(iph->tot_len);
if (skb->len < len) {
__IP_INC_STATS(net, IPSTATS_MIB_INTRUNCATEDPKTS);
goto drop;
} else if (len < (iph->ihl*4))
...

where reason = SKB_DROP_REASON_PKT_TOO_SMALL

rest looks ok to me.


> return skb;
>
> csum_error:
> + drop_reason = SKB_DROP_REASON_IP_CSUM;
> __IP_INC_STATS(net, IPSTATS_MIB_CSUMERRORS);
> inhdr_error:
> + drop_reason = drop_reason ?: SKB_DROP_REASON_IP_INHDR;
> __IP_INC_STATS(net, IPSTATS_MIB_INHDRERRORS);
> drop:
> - kfree_skb(skb);
> + kfree_skb_reason(skb, drop_reason);
> out:
> return NULL;
> }

\
 
 \ /
  Last update: 2022-01-27 17:33    [W:0.304 / U:0.600 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site