mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 18:39:59 +00:00
net: ipv6: add skb drop reasons to ip6_rcv_core()
Replace kfree_skb() used in ip6_rcv_core() with kfree_skb_reason(). No new drop reasons are added. Seems now we use 'SKB_DROP_REASON_IP_INHDR' for too many case during ipv6 header parse or check, just like what 'IPSTATS_MIB_INHDRERRORS' do. Will it be too general and hard to know what happened? Signed-off-by: Menglong Dong <imagedong@tencent.com> Reviewed-by: Jiang Biao <benbjiang@tencent.com> Reviewed-by: Hao Peng <flyingpeng@tencent.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
7d9dbdfbfd
commit
4daf841a2e
1 changed files with 16 additions and 8 deletions
|
@ -145,13 +145,14 @@ static void ip6_list_rcv_finish(struct net *net, struct sock *sk,
|
||||||
static struct sk_buff *ip6_rcv_core(struct sk_buff *skb, struct net_device *dev,
|
static struct sk_buff *ip6_rcv_core(struct sk_buff *skb, struct net_device *dev,
|
||||||
struct net *net)
|
struct net *net)
|
||||||
{
|
{
|
||||||
|
enum skb_drop_reason reason;
|
||||||
const struct ipv6hdr *hdr;
|
const struct ipv6hdr *hdr;
|
||||||
u32 pkt_len;
|
u32 pkt_len;
|
||||||
struct inet6_dev *idev;
|
struct inet6_dev *idev;
|
||||||
|
|
||||||
if (skb->pkt_type == PACKET_OTHERHOST) {
|
if (skb->pkt_type == PACKET_OTHERHOST) {
|
||||||
dev_core_stats_rx_otherhost_dropped_inc(skb->dev);
|
dev_core_stats_rx_otherhost_dropped_inc(skb->dev);
|
||||||
kfree_skb(skb);
|
kfree_skb_reason(skb, SKB_DROP_REASON_OTHERHOST);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,9 +162,12 @@ static struct sk_buff *ip6_rcv_core(struct sk_buff *skb, struct net_device *dev,
|
||||||
|
|
||||||
__IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_IN, skb->len);
|
__IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_IN, skb->len);
|
||||||
|
|
||||||
|
SKB_DR_SET(reason, NOT_SPECIFIED);
|
||||||
if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL ||
|
if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL ||
|
||||||
!idev || unlikely(idev->cnf.disable_ipv6)) {
|
!idev || unlikely(idev->cnf.disable_ipv6)) {
|
||||||
__IP6_INC_STATS(net, idev, IPSTATS_MIB_INDISCARDS);
|
__IP6_INC_STATS(net, idev, IPSTATS_MIB_INDISCARDS);
|
||||||
|
if (unlikely(idev->cnf.disable_ipv6))
|
||||||
|
SKB_DR_SET(reason, IPV6DISABLED);
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,8 +191,10 @@ static struct sk_buff *ip6_rcv_core(struct sk_buff *skb, struct net_device *dev,
|
||||||
|
|
||||||
hdr = ipv6_hdr(skb);
|
hdr = ipv6_hdr(skb);
|
||||||
|
|
||||||
if (hdr->version != 6)
|
if (hdr->version != 6) {
|
||||||
|
SKB_DR_SET(reason, UNHANDLED_PROTO);
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
__IP6_ADD_STATS(net, idev,
|
__IP6_ADD_STATS(net, idev,
|
||||||
IPSTATS_MIB_NOECTPKTS +
|
IPSTATS_MIB_NOECTPKTS +
|
||||||
|
@ -226,8 +232,10 @@ static struct sk_buff *ip6_rcv_core(struct sk_buff *skb, struct net_device *dev,
|
||||||
if (!ipv6_addr_is_multicast(&hdr->daddr) &&
|
if (!ipv6_addr_is_multicast(&hdr->daddr) &&
|
||||||
(skb->pkt_type == PACKET_BROADCAST ||
|
(skb->pkt_type == PACKET_BROADCAST ||
|
||||||
skb->pkt_type == PACKET_MULTICAST) &&
|
skb->pkt_type == PACKET_MULTICAST) &&
|
||||||
idev->cnf.drop_unicast_in_l2_multicast)
|
idev->cnf.drop_unicast_in_l2_multicast) {
|
||||||
|
SKB_DR_SET(reason, UNICAST_IN_L2_MULTICAST);
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
/* RFC4291 2.7
|
/* RFC4291 2.7
|
||||||
* Nodes must not originate a packet to a multicast address whose scope
|
* Nodes must not originate a packet to a multicast address whose scope
|
||||||
|
@ -256,12 +264,11 @@ static struct sk_buff *ip6_rcv_core(struct sk_buff *skb, struct net_device *dev,
|
||||||
if (pkt_len + sizeof(struct ipv6hdr) > skb->len) {
|
if (pkt_len + sizeof(struct ipv6hdr) > skb->len) {
|
||||||
__IP6_INC_STATS(net,
|
__IP6_INC_STATS(net,
|
||||||
idev, IPSTATS_MIB_INTRUNCATEDPKTS);
|
idev, IPSTATS_MIB_INTRUNCATEDPKTS);
|
||||||
|
SKB_DR_SET(reason, PKT_TOO_SMALL);
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr))) {
|
if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr)))
|
||||||
__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);
|
goto err;
|
||||||
goto drop;
|
|
||||||
}
|
|
||||||
hdr = ipv6_hdr(skb);
|
hdr = ipv6_hdr(skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,9 +289,10 @@ static struct sk_buff *ip6_rcv_core(struct sk_buff *skb, struct net_device *dev,
|
||||||
return skb;
|
return skb;
|
||||||
err:
|
err:
|
||||||
__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);
|
__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);
|
||||||
|
SKB_DR_OR(reason, IP_INHDR);
|
||||||
drop:
|
drop:
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
kfree_skb(skb);
|
kfree_skb_reason(skb, reason);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue