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, willemdebruijn.kernel@gmail.com
Cc: Tom Herbert <tom@quantonium.net>, Tom Herbert <tom@herbertland.com>
Subject: [PATCH v8 net-next 1/9] ipeh: Fix destopts counters on drop
Date: Thu, 26 Dec 2019 14:51:30 -0800	[thread overview]
Message-ID: <1577400698-4836-2-git-send-email-tom@herbertland.com> (raw)
In-Reply-To: <1577400698-4836-1-git-send-email-tom@herbertland.com>

From: Tom Herbert <tom@quantonium.net>

Bump IPSTATS_MIB_INHDRERRORS when extension header limit is exceeded.

Only take net from skb->dev, don't use dst for counters.

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

diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index ab5add0..e7eacc4 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -276,28 +276,25 @@ static const struct tlvtype_proc tlvprocdestopt_lst[] = {
 
 static int ipv6_destopt_rcv(struct sk_buff *skb)
 {
-	struct inet6_dev *idev = __in6_dev_get(skb->dev);
 	struct inet6_skb_parm *opt = IP6CB(skb);
 #if IS_ENABLED(CONFIG_IPV6_MIP6)
 	__u16 dstbuf;
 #endif
-	struct dst_entry *dst = skb_dst(skb);
 	struct net *net = dev_net(skb->dev);
 	int extlen;
 
 	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)))) {
-		__IP6_INC_STATS(dev_net(dst->dev), idev,
-				IPSTATS_MIB_INHDRERRORS);
-fail_and_free:
 		kfree_skb(skb);
-		return -1;
+		goto fail;
 	}
 
 	extlen = (skb_transport_header(skb)[1] + 1) << 3;
-	if (extlen > net->ipv6.sysctl.max_dst_opts_len)
-		goto fail_and_free;
+	if (extlen > net->ipv6.sysctl.max_dst_opts_len) {
+		kfree_skb(skb);
+		goto fail;
+	}
 
 	opt->lastopt = opt->dst1 = skb_network_header_len(skb);
 #if IS_ENABLED(CONFIG_IPV6_MIP6)
@@ -316,7 +313,9 @@ static int ipv6_destopt_rcv(struct sk_buff *skb)
 		return 1;
 	}
 
-	__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);
+fail:
+	__IP6_INC_STATS(dev_net(skb->dev), __in6_dev_get(skb->dev),
+			IPSTATS_MIB_INHDRERRORS);
 	return -1;
 }
 
-- 
2.7.4


  reply	other threads:[~2019-12-26 22:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-26 22:51 [PATCH v8 net-next 0/9] ipv6: Extension header infrastructure Tom Herbert
2019-12-26 22:51 ` Tom Herbert [this message]
2019-12-26 22:51 ` [PATCH v8 net-next 2/9] ipeh: Create exthdrs_options.c and ipeh.h Tom Herbert
2019-12-26 22:51 ` [PATCH v8 net-next 3/9] ipeh: Move generic EH functions to exthdrs_common.c Tom Herbert
2019-12-26 22:51 ` [PATCH v8 net-next 4/9] ipeh: Generic TLV parser Tom Herbert
2019-12-26 22:51 ` [PATCH v8 net-next 5/9] ipeh: Add callback to ipeh_parse_tlv to handle errors Tom Herbert
2019-12-26 22:51 ` [PATCH v8 net-next 6/9] ip6tlvs: Registration of TLV handlers and parameters Tom Herbert
2019-12-26 22:51 ` [PATCH v8 net-next 7/9] ip6tlvs: Add TX parameters Tom Herbert
2019-12-26 22:51 ` [PATCH v8 net-next 8/9] ip6tlvs: Add netlink interface Tom Herbert
2019-12-26 22:51 ` [PATCH v8 net-next 9/9] ip6tlvs: Validation of TX Destination and Hop-by-Hop options Tom Herbert
2020-01-02 21:41 ` [PATCH v8 net-next 0/9] ipv6: Extension header infrastructure David Miller
2020-01-03  0:42   ` Tom Herbert
2020-01-03  7:11     ` kernel Dev
2020-01-03 17:35       ` Tom Herbert
2020-01-03 20:45         ` David Miller
2020-01-03 22:31           ` Tom Herbert
2020-01-03 22:57             ` David Miller
2020-01-03 23:48               ` Tom Herbert
2020-01-03 23:53                 ` Erik Kline
2020-01-04  0:37                   ` Tom Herbert
2020-01-04  8:05                     ` kernel Dev
2020-01-04 17:45                       ` Tom Herbert
2020-01-04 19:02                         ` kernel Dev
2020-01-04 19:27                           ` kernel Dev
2020-01-04 20:22                           ` Tom Herbert
2020-01-07 14:27                             ` kernel Dev

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=1577400698-4836-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 \
    --cc=willemdebruijn.kernel@gmail.com \
    /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).