netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Herbert <tom@herbertland.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: David Miller <davem@davemloft.net>,
	Network Development <netdev@vger.kernel.org>,
	Simon Horman <simon.horman@netronome.com>,
	Tom Herbert <tom@quantonium.net>
Subject: Re: [PATCH v6 net-next 1/9] ipeh: Fix destopts and hopopts counters on drop
Date: Mon, 23 Dec 2019 12:02:41 -0800	[thread overview]
Message-ID: <CALx6S34F-ng51-UxvkqKcsEaKAwEKLiAR0PjgsXdjyF3267_5w@mail.gmail.com> (raw)
In-Reply-To: <CA+FuTSd4feUHeTAODKEqt7AXoNgh0sbZYJJXrWg7Tb6GTnDmtA@mail.gmail.com>

On Mon, Dec 23, 2019 at 10:53 AM Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
>
> On Mon, Dec 23, 2019 at 11:53 AM Tom Herbert <tom@herbertland.com> wrote:
> >
> > On Sun, Dec 22, 2019 at 8:21 AM Willem de Bruijn
> > <willemdebruijn.kernel@gmail.com> wrote:
> > >
> > > On Fri, Dec 20, 2019 at 6:39 PM Tom Herbert <tom@herbertland.com> wrote:
> > > >
> > > > 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);
> > >
> > > ip6_rcv_core, the only caller of ipv6_parse_hopopts, checks
> > > skb_valid_dst(skb) before deref. Does this need the same?
> >
> > Hi Willem,
> >
> > Actually, it looks like ipv6_parse_hopopts is doing things the right
> > way. __IP6_INC_STATS is called from ip6_rcv_core if ipv6_parse_hopopts
> > and the net is always taken from skb->dev (not dst) in HBH path. I'll
> > fix destopts to do the same.
>
> I don't entirely follow. The above code uses dev_net(dst->dev). Using
> local variable net, derived from dev_net(skb->dev), here definitely
> sounds good to me, if that's what you meant.

Yes, I'm thinking to just do dev_net(skb->dev) in all cases of
__IP6_INC_STATS for hopopts and destopts.

Tom

  reply	other threads:[~2019-12-23 20:02 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 ` [PATCH v6 net-next 1/9] ipeh: Fix destopts and hopopts counters on drop Tom Herbert
2019-12-22 16:20   ` 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 [this message]
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=CALx6S34F-ng51-UxvkqKcsEaKAwEKLiAR0PjgsXdjyF3267_5w@mail.gmail.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).