diff mbox series

[RFC,net-next] bonding: Remove support for use_carrier

Message ID 2730097.1721581672@famine (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series [RFC,net-next] bonding: Remove support for use_carrier | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 273 this patch: 273
netdev/build_tools success Errors and warnings before: 10 this patch: 10
netdev/cc_maintainers warning 1 maintainers not CCed: j.vosburgh@gmail.com
netdev/build_clang success Errors and warnings before: 281 this patch: 281
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 289 this patch: 289
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 235 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 18 this patch: 18
netdev/source_inline success Was 0 now: 0

Commit Message

Jay Vosburgh July 21, 2024, 5:07 p.m. UTC
Remove the implementation of use_carrier, the link monitoring
method that utilizes ethtool or ioctl to determine the link state of an
interface in a bond.  The ability to set or query the use_carrier option
remains, but bonding now always behaves as if use_carrier=1, which
relies on netif_carrier_ok() to determine the link state of interfaces.

	To avoid acquiring RTNL many times per second, bonding inspects
link state under RCU, but not under RTNL.  However, ethtool
implementations in drivers may sleep, and therefore this strategy is
unsuitable for use with calls into driver ethtool functions.

	The use_carrier option was introduced in 2003, to provide
backwards compatibility for network device drivers that did not support
the then-new netif_carrier_ok/on/off system.  Device drivers are now
expected to support netif_carrier_*, and the use_carrier backwards
compatibility logic is no longer necessary.

Link: https://lore.kernel.org/lkml/000000000000eb54bf061cfd666a@google.com/
Link: https://lore.kernel.org/netdev/20240718122017.d2e33aaac43a.I10ab9c9ded97163aef4e4de10985cd8f7de60d28@changeid/
Signed-off-by: Jay Vosburgh <jv@jvosburgh.net>

---

	I've done some sniff testing and this seems to behave as
expected, except that writing 0 to the sysfs use_carrier fails.  Netlink
permits setting use_carrier to any value but always returns 1; sysfs and
netlink should behave consistently.

 drivers/net/bonding/bond_main.c    | 107 +----------------------------
 drivers/net/bonding/bond_netlink.c |  11 +--
 drivers/net/bonding/bond_options.c |  13 +---
 drivers/net/bonding/bond_sysfs.c   |   6 +-
 include/net/bonding.h              |   1 -
 5 files changed, 7 insertions(+), 131 deletions(-)

Comments

Hangbin Liu July 22, 2024, 3:49 a.m. UTC | #1
On Sun, Jul 21, 2024 at 10:07:52AM -0700, Jay Vosburgh wrote:
> 	Remove the implementation of use_carrier, the link monitoring
> method that utilizes ethtool or ioctl to determine the link state of an
> interface in a bond.  The ability to set or query the use_carrier option
> remains, but bonding now always behaves as if use_carrier=1, which
> relies on netif_carrier_ok() to determine the link state of interfaces.
> 
> 	To avoid acquiring RTNL many times per second, bonding inspects
> link state under RCU, but not under RTNL.  However, ethtool
> implementations in drivers may sleep, and therefore this strategy is
> unsuitable for use with calls into driver ethtool functions.
> 
> 	The use_carrier option was introduced in 2003, to provide
> backwards compatibility for network device drivers that did not support
> the then-new netif_carrier_ok/on/off system.  Device drivers are now
> expected to support netif_carrier_*, and the use_carrier backwards
> compatibility logic is no longer necessary.
> 
> Link: https://lore.kernel.org/lkml/000000000000eb54bf061cfd666a@google.com/
> Link: https://lore.kernel.org/netdev/20240718122017.d2e33aaac43a.I10ab9c9ded97163aef4e4de10985cd8f7de60d28@changeid/
> Signed-off-by: Jay Vosburgh <jv@jvosburgh.net>
> 
> ---
> 
> 	I've done some sniff testing and this seems to behave as
> expected, except that writing 0 to the sysfs use_carrier fails.  Netlink
> permits setting use_carrier to any value but always returns 1; sysfs and
> netlink should behave consistently.
> 
>  drivers/net/bonding/bond_main.c    | 107 +----------------------------
>  drivers/net/bonding/bond_netlink.c |  11 +--
>  drivers/net/bonding/bond_options.c |  13 +---
>  drivers/net/bonding/bond_sysfs.c   |   6 +-
>  include/net/bonding.h              |   1 -
>  5 files changed, 7 insertions(+), 131 deletions(-)
> 
> diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
> index 2a6a424806aa..e35433cd76b1 100644
> --- a/drivers/net/bonding/bond_netlink.c
> +++ b/drivers/net/bonding/bond_netlink.c
> @@ -257,15 +257,6 @@ static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[],
>  		if (err)
>  			return err;
>  	}
> -	if (data[IFLA_BOND_USE_CARRIER]) {
> -		int use_carrier = nla_get_u8(data[IFLA_BOND_USE_CARRIER]);
> -
> -		bond_opt_initval(&newval, use_carrier);
> -		err = __bond_opt_set(bond, BOND_OPT_USE_CARRIER, &newval,
> -				     data[IFLA_BOND_USE_CARRIER], extack);
> -		if (err)
> -			return err;
> -	}

I'm not sure if we should return a warn/error if user want to set this.

BTW, the document also need update.

Others looks good to me.

Thanks
Hangbin
David Wei July 22, 2024, 6:28 a.m. UTC | #2
On 2024-07-21 10:07, Jay Vosburgh wrote:
> 	Remove the implementation of use_carrier, the link monitoring
> method that utilizes ethtool or ioctl to determine the link state of an
> interface in a bond.  The ability to set or query the use_carrier option
> remains, but bonding now always behaves as if use_carrier=1, which
> relies on netif_carrier_ok() to determine the link state of interfaces.
> 
> 	To avoid acquiring RTNL many times per second, bonding inspects
> link state under RCU, but not under RTNL.  However, ethtool
> implementations in drivers may sleep, and therefore this strategy is
> unsuitable for use with calls into driver ethtool functions.
> 
> 	The use_carrier option was introduced in 2003, to provide
> backwards compatibility for network device drivers that did not support
> the then-new netif_carrier_ok/on/off system.  Device drivers are now
> expected to support netif_carrier_*, and the use_carrier backwards
> compatibility logic is no longer necessary.
> 
> Link: https://lore.kernel.org/lkml/000000000000eb54bf061cfd666a@google.com/
> Link: https://lore.kernel.org/netdev/20240718122017.d2e33aaac43a.I10ab9c9ded97163aef4e4de10985cd8f7de60d28@changeid/
> Signed-off-by: Jay Vosburgh <jv@jvosburgh.net>
> 
> ---
> 
> 	I've done some sniff testing and this seems to behave as
> expected, except that writing 0 to the sysfs use_carrier fails.  Netlink
> permits setting use_carrier to any value but always returns 1; sysfs and
> netlink should behave consistently.

Net-next is closed until 28 July. Please resubmit then.
Joe Damato July 22, 2024, 4:19 p.m. UTC | #3
On Sun, Jul 21, 2024 at 11:28:23PM -0700, David Wei wrote:
> On 2024-07-21 10:07, Jay Vosburgh wrote:
> > 	Remove the implementation of use_carrier, the link monitoring
> > method that utilizes ethtool or ioctl to determine the link state of an
> > interface in a bond.  The ability to set or query the use_carrier option
> > remains, but bonding now always behaves as if use_carrier=1, which
> > relies on netif_carrier_ok() to determine the link state of interfaces.
> > 
> > 	To avoid acquiring RTNL many times per second, bonding inspects
> > link state under RCU, but not under RTNL.  However, ethtool
> > implementations in drivers may sleep, and therefore this strategy is
> > unsuitable for use with calls into driver ethtool functions.
> > 
> > 	The use_carrier option was introduced in 2003, to provide
> > backwards compatibility for network device drivers that did not support
> > the then-new netif_carrier_ok/on/off system.  Device drivers are now
> > expected to support netif_carrier_*, and the use_carrier backwards
> > compatibility logic is no longer necessary.
> > 
> > Link: https://lore.kernel.org/lkml/000000000000eb54bf061cfd666a@google.com/
> > Link: https://lore.kernel.org/netdev/20240718122017.d2e33aaac43a.I10ab9c9ded97163aef4e4de10985cd8f7de60d28@changeid/
> > Signed-off-by: Jay Vosburgh <jv@jvosburgh.net>
> > 
> > ---
> > 
> > 	I've done some sniff testing and this seems to behave as
> > expected, except that writing 0 to the sysfs use_carrier fails.  Netlink
> > permits setting use_carrier to any value but always returns 1; sysfs and
> > netlink should behave consistently.
> 
> Net-next is closed until 28 July. Please resubmit then.

AFAICT, the subject line is marked as RFC (although it is a bit
confusing as it mentions both PATCH and RFC), but my understanding
is that RFCs are accepted at any time.
David Wei July 22, 2024, 4:26 p.m. UTC | #4
On 2024-07-22 09:19, Joe Damato wrote:
> On Sun, Jul 21, 2024 at 11:28:23PM -0700, David Wei wrote:
>> On 2024-07-21 10:07, Jay Vosburgh wrote:
>>> 	Remove the implementation of use_carrier, the link monitoring
>>> method that utilizes ethtool or ioctl to determine the link state of an
>>> interface in a bond.  The ability to set or query the use_carrier option
>>> remains, but bonding now always behaves as if use_carrier=1, which
>>> relies on netif_carrier_ok() to determine the link state of interfaces.
>>>
>>> 	To avoid acquiring RTNL many times per second, bonding inspects
>>> link state under RCU, but not under RTNL.  However, ethtool
>>> implementations in drivers may sleep, and therefore this strategy is
>>> unsuitable for use with calls into driver ethtool functions.
>>>
>>> 	The use_carrier option was introduced in 2003, to provide
>>> backwards compatibility for network device drivers that did not support
>>> the then-new netif_carrier_ok/on/off system.  Device drivers are now
>>> expected to support netif_carrier_*, and the use_carrier backwards
>>> compatibility logic is no longer necessary.
>>>
>>> Link: https://lore.kernel.org/lkml/000000000000eb54bf061cfd666a@google.com/
>>> Link: https://lore.kernel.org/netdev/20240718122017.d2e33aaac43a.I10ab9c9ded97163aef4e4de10985cd8f7de60d28@changeid/
>>> Signed-off-by: Jay Vosburgh <jv@jvosburgh.net>
>>>
>>> ---
>>>
>>> 	I've done some sniff testing and this seems to behave as
>>> expected, except that writing 0 to the sysfs use_carrier fails.  Netlink
>>> permits setting use_carrier to any value but always returns 1; sysfs and
>>> netlink should behave consistently.
>>
>> Net-next is closed until 28 July. Please resubmit then.
> 
> AFAICT, the subject line is marked as RFC (although it is a bit
> confusing as it mentions both PATCH and RFC), but my understanding
> is that RFCs are accepted at any time.

Oh you're right, sorry my mistake.
Jiri Pirko July 29, 2024, 6:51 a.m. UTC | #5
Sun, Jul 21, 2024 at 07:07:52PM CEST, jv@jvosburgh.net wrote:
>	Remove the implementation of use_carrier, the link monitoring
>method that utilizes ethtool or ioctl to determine the link state of an
>interface in a bond.  The ability to set or query the use_carrier option
>remains, but bonding now always behaves as if use_carrier=1, which
>relies on netif_carrier_ok() to determine the link state of interfaces.
>
>	To avoid acquiring RTNL many times per second, bonding inspects
>link state under RCU, but not under RTNL.  However, ethtool
>implementations in drivers may sleep, and therefore this strategy is
>unsuitable for use with calls into driver ethtool functions.
>
>	The use_carrier option was introduced in 2003, to provide
>backwards compatibility for network device drivers that did not support
>the then-new netif_carrier_ok/on/off system.  Device drivers are now
>expected to support netif_carrier_*, and the use_carrier backwards
>compatibility logic is no longer necessary.
>
>Link: https://lore.kernel.org/lkml/000000000000eb54bf061cfd666a@google.com/
>Link: https://lore.kernel.org/netdev/20240718122017.d2e33aaac43a.I10ab9c9ded97163aef4e4de10985cd8f7de60d28@changeid/
>Signed-off-by: Jay Vosburgh <jv@jvosburgh.net>

Looks great. This should have been done like 15 years ago :)
diff mbox series

Patch

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index af9ddd3902cc..98d77a9e5cf1 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -141,8 +141,7 @@  module_param(downdelay, int, 0);
 MODULE_PARM_DESC(downdelay, "Delay before considering link down, "
 			    "in milliseconds");
 module_param(use_carrier, int, 0);
-MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; "
-			      "0 for off, 1 for on (default)");
+MODULE_PARM_DESC(use_carrier, "Obsolete, has no effect");
 module_param(mode, charp, 0);
 MODULE_PARM_DESC(mode, "Mode of operation; 0 for balance-rr, "
 		       "1 for active-backup, 2 for balance-xor, "
@@ -723,73 +722,6 @@  const char *bond_slave_link_status(s8 link)
 	}
 }
 
-/* if <dev> supports MII link status reporting, check its link status.
- *
- * We either do MII/ETHTOOL ioctls, or check netif_carrier_ok(),
- * depending upon the setting of the use_carrier parameter.
- *
- * Return either BMSR_LSTATUS, meaning that the link is up (or we
- * can't tell and just pretend it is), or 0, meaning that the link is
- * down.
- *
- * If reporting is non-zero, instead of faking link up, return -1 if
- * both ETHTOOL and MII ioctls fail (meaning the device does not
- * support them).  If use_carrier is set, return whatever it says.
- * It'd be nice if there was a good way to tell if a driver supports
- * netif_carrier, but there really isn't.
- */
-static int bond_check_dev_link(struct bonding *bond,
-			       struct net_device *slave_dev, int reporting)
-{
-	const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
-	int (*ioctl)(struct net_device *, struct ifreq *, int);
-	struct ifreq ifr;
-	struct mii_ioctl_data *mii;
-
-	if (!reporting && !netif_running(slave_dev))
-		return 0;
-
-	if (bond->params.use_carrier)
-		return netif_carrier_ok(slave_dev) ? BMSR_LSTATUS : 0;
-
-	/* Try to get link status using Ethtool first. */
-	if (slave_dev->ethtool_ops->get_link)
-		return slave_dev->ethtool_ops->get_link(slave_dev) ?
-			BMSR_LSTATUS : 0;
-
-	/* Ethtool can't be used, fallback to MII ioctls. */
-	ioctl = slave_ops->ndo_eth_ioctl;
-	if (ioctl) {
-		/* TODO: set pointer to correct ioctl on a per team member
-		 *       bases to make this more efficient. that is, once
-		 *       we determine the correct ioctl, we will always
-		 *       call it and not the others for that team
-		 *       member.
-		 */
-
-		/* We cannot assume that SIOCGMIIPHY will also read a
-		 * register; not all network drivers (e.g., e100)
-		 * support that.
-		 */
-
-		/* Yes, the mii is overlaid on the ifreq.ifr_ifru */
-		strscpy_pad(ifr.ifr_name, slave_dev->name, IFNAMSIZ);
-		mii = if_mii(&ifr);
-		if (ioctl(slave_dev, &ifr, SIOCGMIIPHY) == 0) {
-			mii->reg_num = MII_BMSR;
-			if (ioctl(slave_dev, &ifr, SIOCGMIIREG) == 0)
-				return mii->val_out & BMSR_LSTATUS;
-		}
-	}
-
-	/* If reporting, report that either there's no ndo_eth_ioctl,
-	 * or both SIOCGMIIREG and get_link failed (meaning that we
-	 * cannot report link status).  If not reporting, pretend
-	 * we're ok.
-	 */
-	return reporting ? -1 : BMSR_LSTATUS;
-}
-
 /*----------------------------- Multicast list ------------------------------*/
 
 /* Push the promiscuity flag down to appropriate slaves */
@@ -1832,7 +1764,6 @@  int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 	const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
 	struct slave *new_slave = NULL, *prev_slave;
 	struct sockaddr_storage ss;
-	int link_reporting;
 	int res = 0, i;
 
 	if (slave_dev->flags & IFF_MASTER &&
@@ -1842,12 +1773,6 @@  int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 		return -EPERM;
 	}
 
-	if (!bond->params.use_carrier &&
-	    slave_dev->ethtool_ops->get_link == NULL &&
-	    slave_ops->ndo_eth_ioctl == NULL) {
-		slave_warn(bond_dev, slave_dev, "no link monitoring support\n");
-	}
-
 	/* already in-use? */
 	if (netdev_is_rx_handler_busy(slave_dev)) {
 		SLAVE_NL_ERR(bond_dev, slave_dev, extack,
@@ -2050,29 +1975,10 @@  int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 
 	new_slave->last_tx = new_slave->last_rx;
 
-	if (bond->params.miimon && !bond->params.use_carrier) {
-		link_reporting = bond_check_dev_link(bond, slave_dev, 1);
-
-		if ((link_reporting == -1) && !bond->params.arp_interval) {
-			/* miimon is set but a bonded network driver
-			 * does not support ETHTOOL/MII and
-			 * arp_interval is not set.  Note: if
-			 * use_carrier is enabled, we will never go
-			 * here (because netif_carrier is always
-			 * supported); thus, we don't need to change
-			 * the messages for netif_carrier.
-			 */
-			slave_warn(bond_dev, slave_dev, "MII and ETHTOOL support not available for slave, and arp_interval/arp_ip_target module parameters not specified, thus bonding will not detect link failures! see bonding.txt for details\n");
-		} else if (link_reporting == -1) {
-			/* unable get link status using mii/ethtool */
-			slave_warn(bond_dev, slave_dev, "can't get link status from slave; the network driver associated with this interface does not support MII or ETHTOOL link status reporting, thus miimon has no effect on this interface\n");
-		}
-	}
-
 	/* check for initial state */
 	new_slave->link = BOND_LINK_NOCHANGE;
 	if (bond->params.miimon) {
-		if (bond_check_dev_link(bond, slave_dev, 0) == BMSR_LSTATUS) {
+		if (netif_carrier_ok(slave_dev)) {
 			if (bond->params.updelay) {
 				bond_set_slave_link_state(new_slave,
 							  BOND_LINK_BACK,
@@ -2601,7 +2507,7 @@  static int bond_miimon_inspect(struct bonding *bond)
 	bond_for_each_slave_rcu(bond, slave, iter) {
 		bond_propose_link_state(slave, BOND_LINK_NOCHANGE);
 
-		link_state = bond_check_dev_link(bond, slave->dev, 0);
+		link_state = netif_carrier_ok(slave->dev);
 
 		switch (slave->link) {
 		case BOND_LINK_UP:
@@ -6044,12 +5950,6 @@  static int __init bond_check_params(struct bond_params *params)
 		downdelay = 0;
 	}
 
-	if ((use_carrier != 0) && (use_carrier != 1)) {
-		pr_warn("Warning: use_carrier module parameter (%d), not of valid value (0/1), so it was set to 1\n",
-			use_carrier);
-		use_carrier = 1;
-	}
-
 	if (num_peer_notif < 0 || num_peer_notif > 255) {
 		pr_warn("Warning: num_grat_arp/num_unsol_na (%d) not in range 0-255 so it was reset to 1\n",
 			num_peer_notif);
@@ -6294,7 +6194,6 @@  static int __init bond_check_params(struct bond_params *params)
 	params->updelay = updelay;
 	params->downdelay = downdelay;
 	params->peer_notif_delay = 0;
-	params->use_carrier = use_carrier;
 	params->lacp_active = 1;
 	params->lacp_fast = lacp_fast;
 	params->primary[0] = 0;
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index 2a6a424806aa..e35433cd76b1 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -257,15 +257,6 @@  static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[],
 		if (err)
 			return err;
 	}
-	if (data[IFLA_BOND_USE_CARRIER]) {
-		int use_carrier = nla_get_u8(data[IFLA_BOND_USE_CARRIER]);
-
-		bond_opt_initval(&newval, use_carrier);
-		err = __bond_opt_set(bond, BOND_OPT_USE_CARRIER, &newval,
-				     data[IFLA_BOND_USE_CARRIER], extack);
-		if (err)
-			return err;
-	}
 	if (data[IFLA_BOND_ARP_INTERVAL]) {
 		int arp_interval = nla_get_u32(data[IFLA_BOND_ARP_INTERVAL]);
 
@@ -674,7 +665,7 @@  static int bond_fill_info(struct sk_buff *skb,
 			bond->params.peer_notif_delay * bond->params.miimon))
 		goto nla_put_failure;
 
-	if (nla_put_u8(skb, IFLA_BOND_USE_CARRIER, bond->params.use_carrier))
+	if (nla_put_u8(skb, IFLA_BOND_USE_CARRIER, 1))
 		goto nla_put_failure;
 
 	if (nla_put_u32(skb, IFLA_BOND_ARP_INTERVAL, bond->params.arp_interval))
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index bc80fb6397dc..ab5db55e27ea 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -183,12 +183,6 @@  static const struct bond_opt_value bond_primary_reselect_tbl[] = {
 	{ NULL,      -1},
 };
 
-static const struct bond_opt_value bond_use_carrier_tbl[] = {
-	{ "off", 0,  0},
-	{ "on",  1,  BOND_VALFLAG_DEFAULT},
-	{ NULL,  -1, 0}
-};
-
 static const struct bond_opt_value bond_all_slaves_active_tbl[] = {
 	{ "off", 0,  BOND_VALFLAG_DEFAULT},
 	{ "on",  1,  0},
@@ -410,8 +404,7 @@  static const struct bond_option bond_opts[BOND_OPT_LAST] = {
 	[BOND_OPT_USE_CARRIER] = {
 		.id = BOND_OPT_USE_CARRIER,
 		.name = "use_carrier",
-		.desc = "Use netif_carrier_ok (vs MII ioctls) in miimon",
-		.values = bond_use_carrier_tbl,
+		.desc = "Obsolete, has no effect",
 		.set = bond_option_use_carrier_set
 	},
 	[BOND_OPT_ACTIVE_SLAVE] = {
@@ -1064,10 +1057,6 @@  static int bond_option_peer_notif_delay_set(struct bonding *bond,
 static int bond_option_use_carrier_set(struct bonding *bond,
 				       const struct bond_opt_value *newval)
 {
-	netdev_dbg(bond->dev, "Setting use_carrier to %llu\n",
-		   newval->value);
-	bond->params.use_carrier = newval->value;
-
 	return 0;
 }
 
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 1e13bb170515..9a75ad3181ab 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -467,14 +467,12 @@  static ssize_t bonding_show_primary_reselect(struct device *d,
 static DEVICE_ATTR(primary_reselect, 0644,
 		   bonding_show_primary_reselect, bonding_sysfs_store_option);
 
-/* Show the use_carrier flag. */
+/* use_carrier is obsolete, but print value for compatibility */
 static ssize_t bonding_show_carrier(struct device *d,
 				    struct device_attribute *attr,
 				    char *buf)
 {
-	struct bonding *bond = to_bond(d);
-
-	return sysfs_emit(buf, "%d\n", bond->params.use_carrier);
+	return sysfs_emit(buf, "1\n");
 }
 static DEVICE_ATTR(use_carrier, 0644,
 		   bonding_show_carrier, bonding_sysfs_store_option);
diff --git a/include/net/bonding.h b/include/net/bonding.h
index b61fb1aa3a56..2977a9bc343b 100644
--- a/include/net/bonding.h
+++ b/include/net/bonding.h
@@ -124,7 +124,6 @@  struct bond_params {
 	int arp_interval;
 	int arp_validate;
 	int arp_all_targets;
-	int use_carrier;
 	int fail_over_mac;
 	int updelay;
 	int downdelay;