netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Sabrina Dubroca <sd@queasysnail.net>
Cc: Florian Westphal <fw@strlen.de>,
	netdev@vger.kernel.org,
	Hannes Frederic Sowa <hannes@stressinduktion.org>
Subject: Re: [RFC PATCH net-next 3/3] macsec: introduce IEEE 802.1AE driver
Date: Mon, 4 Jan 2016 13:23:29 +0100	[thread overview]
Message-ID: <20160104122329.GB470@breakpoint.cc> (raw)
In-Reply-To: <20151229135618.GA28245@bistromath.redhat.com>

Sabrina Dubroca <sd@queasysnail.net> wrote:

[ Sorry for long delay ]

> 2015-12-29, 02:14:06 +0100, Florian Westphal wrote:
> > > +	tx_sa->next_pn++;
> > > +	if (tx_sa->next_pn == 0) {
> > > +		pr_notice("PN wrapped, transitionning to !oper\n");
> > 
> > Is that _notice intentional?
> > I'm only asking because it seems we printk unconditionally in response
> > to network traffic & I don't get what operator should do in response to
> > that message.
> 
> The operator should install a new tx_sa, or MKA should have already
> installed a new one and switched to it.
> I can remove this message, or make it a pr_debug.

Ok, I'll leave it up to you since I don't know what makes more sense.
Basically just do whatever you think is right ;)

AFAIU this should not really happen in practice, right?

If so, pr_debug might be appropriate.

> > > +static void macsec_encrypt_done(struct crypto_async_request *base, int err)
> > > +{
> > > +	struct sk_buff *skb = base->data;
> > > +	struct net_device *dev = skb->dev;
> > > +	struct macsec_dev *macsec = macsec_priv(dev);
> > > +	struct macsec_tx_sa *sa = macsec_skb_cb(skb)->tx_sa;
> > > +	int len, ret;
> > > +
> > > +	aead_request_free(macsec_skb_cb(skb)->req);
> > > +
> > > +	rcu_read_lock_bh();
> > > +	macsec_encrypt_finish(skb, dev);
> > > +	macsec_count_tx(skb, &macsec->secy.tx_sc, macsec_skb_cb(skb)->tx_sa);
> > > +	len = skb->len;
> > > +	ret = dev_queue_xmit(skb);
> > > +	count_tx(dev, ret, len);
> > > +	rcu_read_unlock_bh();
> > 
> > What was the rcu_read_lock_bh protecting?
> 
> this_cpu_ptr in macsec_count_tx and count_tx.  Separate get_cpu_ptr in
> both functions seem a bit wasteful, and dev_queue_xmit will also
> disable bh.
> 
> I could turn that into a preempt_disable with a comment (something
> like "covers multiple accesses to pcpu variables").  Or I could get
> rid of it, and use get/put_cpu_ptr in macsec_count_tx/count_tx.
> Note that macsec_count_tx/count_tx (and count_rx below) are also
> called from the normal packet processing path, where we already run
> under rcu_read_lock_bh anyway, so avoiding the overhead of an extra
> get_cpu_ptr seems preferable.

Ah, I see.  In that case it seems preferrable to local_bh_dis/enable
here.  What do you think? (comment is still good to have wrt. pcpu and
packet processing path detail, I missed the latter).

> > > +		spin_unlock(&rx_sa->lock);
> > > +		pr_debug("packet_number too small: %u < %u\n", pn, lowest_pn);
> > > +		u64_stats_update_begin(&rxsc_stats->syncp);
> > > +		rxsc_stats->stats.InPktsLate++;
> > > +		u64_stats_update_end(&rxsc_stats->syncp);
> > > +		goto drop;
> > > +	}
> > 
> > I don't understand why this seems to perform replay check twice?
> 
> This is part of the specification (802.1AE-2006 figure 10-5).
> The first check is done before attempting to decrypt the packet, then
> once again after decrypting.

I see. Could you add a short comment?
("re-check post decryption as per $ref $figure" or something like that
 should suffice).

> > > +	if (secy->validate_frames != MACSEC_VALIDATE_DISABLED) {
> > > +		u64_stats_update_begin(&rxsc_stats->syncp);
> > > +		if (hdr->tci_an & MACSEC_TCI_E)
> > > +			rxsc_stats->stats.InOctetsDecrypted += skb->len;
> > > +		else
> > > +			rxsc_stats->stats.InOctetsValidated += skb->len;
> > > +		u64_stats_update_end(&rxsc_stats->syncp);
> > > +	}
[..]
> > Do you think its feasible to rearrange the above so that
> > rx_sa->lock/unlock (next_pn test and increment) are grouped more closesly?
> 
> Not if we want to follow the order of the checks in the specification.

Ok, thanks for explaining.

  reply	other threads:[~2016-01-04 12:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-28 12:38 [RFC PATCH net-next 0/3] MACsec IEEE 802.1AE implementation Sabrina Dubroca
2015-12-28 12:38 ` [RFC PATCH net-next 1/3] uapi: add MACsec bits Sabrina Dubroca
2015-12-28 12:38 ` [RFC PATCH net-next 2/3] net: add MACsec netdevice priv_flags and helper Sabrina Dubroca
2015-12-28 12:38 ` [RFC PATCH net-next 3/3] macsec: introduce IEEE 802.1AE driver Sabrina Dubroca
2015-12-29  1:14   ` Florian Westphal
2015-12-29 13:56     ` Sabrina Dubroca
2016-01-04 12:23       ` Florian Westphal [this message]
2016-01-05 10:04   ` Paolo Abeni
2016-01-08 18:06     ` Sabrina Dubroca

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=20160104122329.GB470@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=hannes@stressinduktion.org \
    --cc=netdev@vger.kernel.org \
    --cc=sd@queasysnail.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).