diff mbox

[net-next] libcxgbi/cxgb4i : Fix ipv6 build failure caught with randconfig

Message ID 1407880481-22352-1-git-send-email-anish@chelsio.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Anish Bhatt Aug. 12, 2014, 9:54 p.m. UTC
Previous guard of IS_ENABLED(CONFIG_IPV6) is not sufficient when cxgbi drivers
are built into kernel but ipv6 is not. Change guard to only enable when either
ipv6 is built-in or both are modules.

Fixes: e81fbf6cd652 ("libcxgbi:cxgb4i Guard ipv6 code with a config check")
Fixes: fc8d0590d914 ("libcxgbi: Add ipv6 api to driver")
Signed-off-by: Anish Bhatt <anish@chelsio.com>
---
 drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | 13 +++++++------
 drivers/scsi/cxgbi/libcxgbi.c      |  9 ++++++---
 2 files changed, 13 insertions(+), 9 deletions(-)

Comments

David Miller Aug. 12, 2014, 10 p.m. UTC | #1
From: Anish Bhatt <anish@chelsio.com>
Date: Tue, 12 Aug 2014 14:54:41 -0700

> Previous guard of IS_ENABLED(CONFIG_IPV6) is not sufficient when cxgbi drivers
> are built into kernel but ipv6 is not. Change guard to only enable when either
> ipv6 is built-in or both are modules.
> 
> Fixes: e81fbf6cd652 ("libcxgbi:cxgb4i Guard ipv6 code with a config check")
> Fixes: fc8d0590d914 ("libcxgbi: Add ipv6 api to driver")
> Signed-off-by: Anish Bhatt <anish@chelsio.com>

Why are you targetting a serious fix at the net-next tree?

'net-next' is for new features and cleanups, whereas 'net' is for
bug fixes.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Aug. 12, 2014, 10:22 p.m. UTC | #2
From: Anish Bhatt <anish@chelsio.com>
Date: Tue, 12 Aug 2014 14:54:41 -0700

> Previous guard of IS_ENABLED(CONFIG_IPV6) is not sufficient when cxgbi drivers
> are built into kernel but ipv6 is not. Change guard to only enable when either
> ipv6 is built-in or both are modules.
> 
> Fixes: e81fbf6cd652 ("libcxgbi:cxgb4i Guard ipv6 code with a config check")
> Fixes: fc8d0590d914 ("libcxgbi: Add ipv6 api to driver")
> Signed-off-by: Anish Bhatt <anish@chelsio.com>

That's not how you fix problems like this.

Instead, you should use Kconfig conditions to make sure your driver is
enabled in a manner which is compatible with what IPV6 has been set to.

No user should have to know about these strange dependencies just to get
IPV6 enabled in your driver.

Really, your change makes IPV6 get disabled if IPV6 is modular and your
driver is built statically.  I do not think any user would consider that
reasonable behavior.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Anish Bhatt Aug. 12, 2014, 10:40 p.m. UTC | #3
So the recommended fix would be that the inbuilt option for cxgbi should be
disabled if ipv6 is compiled as a module ?

This patch was based on code currently in net-next, and I presumed that would
be the correct way to go. I'll change it and rebase to net.
-Anish
David Miller Aug. 12, 2014, 10:46 p.m. UTC | #4
From: Anish Bhatt <anish@chelsio.com>
Date: Tue, 12 Aug 2014 22:40:35 +0000

> So the recommended fix would be that the inbuilt option for cxgbi
> should be disabled if ipv6 is compiled as a module ?

If IPV6 is enabled, you should only allow cxgbi to be enabled in
a mode which is "compatible" with that setting.

This means if IPV6 is enabled statically, cxgbi should be offered
both statically and modular.  Whereas if IPV6 is modular, cxgbi
should only be offered to be enabled modular.

This occurs often enough that there is a common pattern for this
kind of dependency:

	depends on IPV6 || IPV6=n

Alternatively, depending upon what IPV6 interfaces you need to use
in the cxgbi driver, you can potentially move them into the ipv6
components we've split out to always be statically built into the
kernel in order to avoid problems of this nature.  See the code
linked in by the "obj-y +=" rule in net/ipv6/Makefile.

> This patch was based on code currently in net-next, and I presumed that would
> be the correct way to go. I'll change it and rebase to net.

The net-next tree isn't even open and active at this time, I said last week
(as I do every single merge window) that I would explicitly announce on
netdev when the net-next tree is openned.

But, much more importantly, bug fixes for issues present in 'net'
should always be targetted to the 'net' tree.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Anish Bhatt Aug. 12, 2014, 10:54 p.m. UTC | #5
>Alternatively, depending upon what IPV6 interfaces you need to use
>in the cxgbi driver, you can potentially move them into the ipv6
>components we've split out to always be statically built into the
>kernel in order to avoid problems of this nature.  See the code
>linked in by the "obj-y +=" rule in net/ipv6/Makefile.

Got it, will fix accordingly.

>> This patch was based on code currently in net-next, and I presumed that would
>> be the correct way to go. I'll change it and rebase to net.

>The net-next tree isn't even open and active at this time, I said last week
>(as I do every single merge window) that I would explicitly announce on
>netdev when the net-next tree is openned.

No, I meant the fix I proposed is currently being used by other code already present in the 
kernel. I'll try and fix that as well.

>But, much more importantly, bug fixes for issues present in 'net'
>should always be targetted to the 'net' tree.

My bad, I was not aware this code made it back to net.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
index 79788a12712d..b5eb7c5f4529 100644
--- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
+++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
@@ -1289,7 +1289,7 @@  static int init_act_open(struct cxgbi_sock *csk)
 
 	if (csk->csk_family == AF_INET)
 		daddr = &csk->daddr.sin_addr.s_addr;
-#if IS_ENABLED(CONFIG_IPV6)
+#if defined(CONFIG_IPV6) || (defined(CONFIG_IPV6_MODULE) && defined(MODULE))
 	else if (csk->csk_family == AF_INET6)
 		daddr = &csk->daddr6.sin6_addr;
 #endif
@@ -1635,7 +1635,7 @@  static int cxgb4i_ddp_init(struct cxgbi_device *cdev)
 	return 0;
 }
 
-#if IS_ENABLED(CONFIG_IPV6)
+#if defined(CONFIG_IPV6) || (defined(CONFIG_IPV6_MODULE) && defined(MODULE))
 static int cxgbi_inet6addr_handler(struct notifier_block *this,
 				   unsigned long event, void *data)
 {
@@ -1756,7 +1756,8 @@  static void cxgbi_update_clip(struct cxgbi_device *cdev)
 	}
 	rcu_read_unlock();
 }
-#endif /* IS_ENABLED(CONFIG_IPV6) */
+#endif /* defined(CONFIG_IPV6) ||
+ (defined(CONFIG_IPV6_MODULE) && defined(MODULE)) */
 
 static void *t4_uld_add(const struct cxgb4_lld_info *lldi)
 {
@@ -1876,7 +1877,7 @@  static int t4_uld_state_change(void *handle, enum cxgb4_state state)
 	switch (state) {
 	case CXGB4_STATE_UP:
 		pr_info("cdev 0x%p, UP.\n", cdev);
-#if IS_ENABLED(CONFIG_IPV6)
+#if defined(CONFIG_IPV6) || (defined(CONFIG_IPV6_MODULE) && defined(MODULE))
 		cxgbi_update_clip(cdev);
 #endif
 		/* re-initialize */
@@ -1910,7 +1911,7 @@  static int __init cxgb4i_init_module(void)
 		return rc;
 	cxgb4_register_uld(CXGB4_ULD_ISCSI, &cxgb4i_uld_info);
 
-#if IS_ENABLED(CONFIG_IPV6)
+#if defined(CONFIG_IPV6) || (defined(CONFIG_IPV6_MODULE) && defined(MODULE))
 	register_inet6addr_notifier(&cxgbi_inet6addr_notifier);
 #endif
 	return 0;
@@ -1918,7 +1919,7 @@  static int __init cxgb4i_init_module(void)
 
 static void __exit cxgb4i_exit_module(void)
 {
-#if IS_ENABLED(CONFIG_IPV6)
+#if defined(CONFIG_IPV6) || (defined(CONFIG_IPV6_MODULE) && defined(MODULE))
 	unregister_inet6addr_notifier(&cxgbi_inet6addr_notifier);
 #endif
 	cxgb4_unregister_uld(CXGB4_ULD_ISCSI);
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index d65df6dc106f..6e56c40040c2 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -560,6 +560,8 @@  static struct cxgbi_sock *cxgbi_check_route(struct sockaddr *dst_addr)
 	}
 
 	cdev = cxgbi_device_find_by_netdev(ndev, &port);
+	if (!cdev)
+		cdev = cxgbi_device_find_by_mac(ndev, &port);
 	if (!cdev) {
 		pr_info("dst %pI4, %s, NOT cxgbi device.\n",
 			&daddr->sin_addr.s_addr, ndev->name);
@@ -602,7 +604,7 @@  err_out:
 	return ERR_PTR(err);
 }
 
-#if IS_ENABLED(CONFIG_IPV6)
+#if defined(CONFIG_IPV6) || (defined(CONFIG_IPV6_MODULE) && defined(MODULE))
 static struct rt6_info *find_route_ipv6(const struct in6_addr *saddr,
 					const struct in6_addr *daddr)
 {
@@ -717,7 +719,8 @@  rel_rt:
 err_out:
 	return ERR_PTR(err);
 }
-#endif /* IS_ENABLED(CONFIG_IPV6) */
+#endif /* defined(CONFIG_IPV6) ||
+ (defined(CONFIG_IPV6_MODULE) && defined(MODULE)) */
 
 void cxgbi_sock_established(struct cxgbi_sock *csk, unsigned int snd_isn,
 			unsigned int opt)
@@ -2640,7 +2643,7 @@  struct iscsi_endpoint *cxgbi_ep_connect(struct Scsi_Host *shost,
 
 	if (dst_addr->sa_family == AF_INET) {
 		csk = cxgbi_check_route(dst_addr);
-#if IS_ENABLED(CONFIG_IPV6)
+#if defined(CONFIG_IPV6) || (defined(CONFIG_IPV6_MODULE) && defined(MODULE))
 	} else if (dst_addr->sa_family == AF_INET6) {
 		csk = cxgbi_check_route6(dst_addr);
 #endif