Netdev List
 help / color / mirror / Atom feed
From: Shannon Nelson <shannon.nelson@oracle.com>
To: steffen.klassert@secunet.com
Cc: netdev@vger.kernel.org
Subject: [PATCH v2 ipsec-next 2/3] xfrm: check for xdo_dev_ops add and delete
Date: Thu, 14 Dec 2017 13:01:16 -0800	[thread overview]
Message-ID: <1513285277-21092-3-git-send-email-shannon.nelson@oracle.com> (raw)
In-Reply-To: <1513285277-21092-1-git-send-email-shannon.nelson@oracle.com>

This adds a check for the required add and delete functions up front
at registration time to be sure both are defined.

Signed-off-by: Shannon Nelson <shannon.nelson@oracle.com>
---
 net/xfrm/xfrm_device.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
index 30e5746..5eb6b82 100644
--- a/net/xfrm/xfrm_device.c
+++ b/net/xfrm/xfrm_device.c
@@ -144,11 +144,19 @@ EXPORT_SYMBOL_GPL(xfrm_dev_offload_ok);
 
 static int xfrm_dev_register(struct net_device *dev)
 {
-	if ((dev->features & NETIF_F_HW_ESP) && !dev->xfrmdev_ops)
-		return NOTIFY_BAD;
-	if ((dev->features & NETIF_F_HW_ESP_TX_CSUM) &&
-	    !(dev->features & NETIF_F_HW_ESP))
+	if (!(dev->features & NETIF_F_HW_ESP)) {
+		if (dev->features & NETIF_F_HW_ESP_TX_CSUM)
+			return NOTIFY_BAD;
+		else
+			return NOTIFY_DONE;
+	}
+
+#ifdef CONFIG_XFRM_OFFLOAD
+	if (!(dev->xfrmdev_ops &&
+	      dev->xfrmdev_ops->xdo_dev_state_add &&
+	      dev->xfrmdev_ops->xdo_dev_state_delete))
 		return NOTIFY_BAD;
+#endif
 
 	return NOTIFY_DONE;
 }
-- 
2.7.4

  parent reply	other threads:[~2017-12-14 21:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-14 21:01 [PATCH v2 ipsec-next 0/3] xfrm: offload api fixes Shannon Nelson
2017-12-14 21:01 ` [PATCH v2 ipsec-next 1/3] xfrm: check for xdo_dev_state_free Shannon Nelson
2017-12-14 21:01 ` Shannon Nelson [this message]
2017-12-14 21:01 ` [PATCH v2 ipsec-next 3/3] xfrm: wrap xfrmdev_ops with offload config Shannon Nelson
2017-12-16 19:12   ` kbuild test robot
2017-12-16 20:04   ` kbuild test robot

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=1513285277-21092-3-git-send-email-shannon.nelson@oracle.com \
    --to=shannon.nelson@oracle.com \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.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