netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Herbert <tom@herbertland.com>
To: davem@davemloft.net, netdev@vger.kernel.org, simon.horman@netronome.com
Cc: Tom Herbert <tom@quantonium.net>, Tom Herbert <tom@herbertland.com>
Subject: [PATCH v6 net-next 1/9] ipeh: Fix destopts and hopopts counters on drop
Date: Fri, 20 Dec 2019 15:38:36 -0800	[thread overview]
Message-ID: <1576885124-14576-2-git-send-email-tom@herbertland.com> (raw)
In-Reply-To: <1576885124-14576-1-git-send-email-tom@herbertland.com>

From: Tom Herbert <tom@quantonium.net>

For destopts, bump IPSTATS_MIB_INHDRERRORS when limit of length
of extension header is exceeded.

For hop-by-hop options, bump IPSTATS_MIB_INHDRERRORS in same
situations as for when destopts are dropped.

Signed-off-by: Tom Herbert <tom@herbertland.com>
---
 net/ipv6/exthdrs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index ab5add0..f605e4e 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -288,9 +288,9 @@ static int ipv6_destopt_rcv(struct sk_buff *skb)
 	if (!pskb_may_pull(skb, skb_transport_offset(skb) + 8) ||
 	    !pskb_may_pull(skb, (skb_transport_offset(skb) +
 				 ((skb_transport_header(skb)[1] + 1) << 3)))) {
+fail_and_free:
 		__IP6_INC_STATS(dev_net(dst->dev), idev,
 				IPSTATS_MIB_INHDRERRORS);
-fail_and_free:
 		kfree_skb(skb);
 		return -1;
 	}
@@ -820,8 +820,10 @@ static const struct tlvtype_proc tlvprochopopt_lst[] = {
 
 int ipv6_parse_hopopts(struct sk_buff *skb)
 {
+	struct inet6_dev *idev = __in6_dev_get(skb->dev);
 	struct inet6_skb_parm *opt = IP6CB(skb);
 	struct net *net = dev_net(skb->dev);
+	struct dst_entry *dst = skb_dst(skb);
 	int extlen;
 
 	/*
@@ -834,6 +836,8 @@ int ipv6_parse_hopopts(struct sk_buff *skb)
 	    !pskb_may_pull(skb, (sizeof(struct ipv6hdr) +
 				 ((skb_transport_header(skb)[1] + 1) << 3)))) {
 fail_and_free:
+		__IP6_INC_STATS(dev_net(dst->dev), idev,
+				IPSTATS_MIB_INHDRERRORS);
 		kfree_skb(skb);
 		return -1;
 	}
@@ -850,6 +854,7 @@ int ipv6_parse_hopopts(struct sk_buff *skb)
 		opt->nhoff = sizeof(struct ipv6hdr);
 		return 1;
 	}
+	__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);
 	return -1;
 }
 
-- 
2.7.4


  reply	other threads:[~2019-12-20 23:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-20 23:38 [PATCH v6 net-next 0/9] ipv6: Extension header infrastructure Tom Herbert
2019-12-20 23:38 ` Tom Herbert [this message]
2019-12-22 16:20   ` [PATCH v6 net-next 1/9] ipeh: Fix destopts and hopopts counters on drop Willem de Bruijn
2019-12-23 16:53     ` Tom Herbert
2019-12-23 18:52       ` Willem de Bruijn
2019-12-23 20:02         ` Tom Herbert
2019-12-20 23:38 ` [PATCH v6 net-next 2/9] ipeh: Create exthdrs_options.c and ipeh.h Tom Herbert
2019-12-20 23:38 ` [PATCH v6 net-next 3/9] ipeh: Move generic EH functions to exthdrs_common.c Tom Herbert
2019-12-20 23:38 ` [PATCH v6 net-next 4/9] ipeh: Generic TLV parser Tom Herbert
2019-12-20 23:38 ` [PATCH v6 net-next 5/9] ipeh: Add callback to ipeh_parse_tlv to handle errors Tom Herbert
2019-12-20 23:38 ` [PATCH v6 net-next 6/9] ip6tlvs: Registration of TLV handlers and parameters Tom Herbert
2019-12-20 23:38 ` [PATCH v6 net-next 7/9] ip6tlvs: Add TX parameters Tom Herbert
2019-12-20 23:38 ` [PATCH v6 net-next 8/9] ip6tlvs: Add netlink interface Tom Herbert
2019-12-20 23:38 ` [PATCH v6 net-next 9/9] ip6tlvs: Validation of TX Destination and Hop-by-Hop options Tom Herbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1576885124-14576-2-git-send-email-tom@herbertland.com \
    --to=tom@herbertland.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=simon.horman@netronome.com \
    --cc=tom@quantonium.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).