svn commit: r236178 - in head: sbin/ifconfig sys/net

2012-05-28 Thread Eygene Ryabinkin
Author: rea (ports committer)
Date: Mon May 28 12:13:04 2012
New Revision: 236178
URL: http://svn.freebsd.org/changeset/base/236178

Log:
  if_lagg: allow to invoke SIOCSLAGGPORT multiple times in a row
  
  Currently, 'ifconfig laggX down' does not remove members from this
  lagg(4) interface.  So, 'service netif stop laggX' followed by
  'service netif start laggX' will choke, because stop will leave
  interfaces attached to the laggX and ifconfig from the start will
  refuse to add already-existing interfaces.
  
  The real-world case is when I am bundling together my Ethernet and
  WiFi interfaces and using multiple profiles for accessing network in
  different places: system being booted up with one profile, but later
  this profile being exchanged to another one, followed by 'service
  netif restart' will not add WiFi interface back to the lagg: the
  stop action from 'service netif restart' will shut down my main WiFi
  interface, so wlan0 that exists in the lagg0 will be destroyed and
  purged from lagg0; the start action will try to re-add both
  interfaces, but since Ethernet one is already in lagg0, ifconfig will
  refuse to add the wlan0 from WiFi interface.
  
  Since adding the interface to the lagg(4) when it is already here
  should be an idempotent action: we're really not changing anything,
  so this fix doesn't change the semantics of interface addition.
  
  Approved by: thompsa
  Reviewed by: emaste
  MFC after: 1 week

Modified:
  head/sbin/ifconfig/iflagg.c
  head/sys/net/if_lagg.c

Modified: head/sbin/ifconfig/iflagg.c
==
--- head/sbin/ifconfig/iflagg.c Mon May 28 12:11:00 2012(r236177)
+++ head/sbin/ifconfig/iflagg.c Mon May 28 12:13:04 2012(r236178)
@@ -40,7 +40,8 @@ setlaggport(const char *val, int d, int 
strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname));
strlcpy(rp.rp_portname, val, sizeof(rp.rp_portname));
 
-   if (ioctl(s, SIOCSLAGGPORT, rp))
+   /* Don't choke if the port is already in this lagg. */
+   if (ioctl(s, SIOCSLAGGPORT, rp)  errno != EEXIST)
err(1, SIOCSLAGGPORT);
 }
 

Modified: head/sys/net/if_lagg.c
==
--- head/sys/net/if_lagg.c  Mon May 28 12:11:00 2012(r236177)
+++ head/sys/net/if_lagg.c  Mon May 28 12:13:04 2012(r236178)
@@ -516,8 +516,13 @@ lagg_port_create(struct lagg_softc *sc, 
return (ENOSPC);
 
/* Check if port has already been associated to a lagg */
-   if (ifp-if_lagg != NULL)
+   if (ifp-if_lagg != NULL) {
+   /* Port is already in the current lagg? */
+   lp = (struct lagg_port *)ifp-if_lagg;
+   if (lp-lp_softc == sc)
+   return (EEXIST);
return (EBUSY);
+   }
 
/* XXX Disallow non-ethernet interfaces (this should be any of 802) */
if (ifp-if_type != IFT_ETHER)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r236178 - in head: sbin/ifconfig sys/net

2012-05-28 Thread Gleb Smirnoff
On Mon, May 28, 2012 at 12:13:05PM +, Eygene Ryabinkin wrote:
E   The real-world case is when I am bundling together my Ethernet and
E   WiFi interfaces and using multiple profiles for accessing network in
E   different places: system being booted up with one profile, but later
E   this profile being exchanged to another one, followed by 'service
E   netif restart' will not add WiFi interface back to the lagg: the
E   stop action from 'service netif restart' will shut down my main WiFi
E   interface, so wlan0 that exists in the lagg0 will be destroyed and
E   purged from lagg0; the start action will try to re-add both
E   interfaces, but since Ethernet one is already in lagg0, ifconfig will
E   refuse to add the wlan0 from WiFi interface.

Although the lagg(4) change is definetely a needed fix, the way of network
roaming via stacking WiFi and Ethernet into lagg(4) always looked like
a huge crutch to me.

Isn't the problem solvable via a some kind of smarter dhclient? How other
UNIX-like OS-es solve this?

-- 
Totus tuus, Glebius.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r236178 - in head: sbin/ifconfig sys/net

2012-05-28 Thread Eygene Ryabinkin
Gleb, good day.

Mon, May 28, 2012 at 05:14:22PM +0400, Gleb Smirnoff wrote:
 the way of network roaming via stacking WiFi and Ethernet into
 lagg(4) always looked like a huge crutch to me.

Why?

 Isn't the problem solvable via a some kind of smarter dhclient?

It isn't always bound to DHCP: just now I am sitting at $WORK
and travelling via the building with WiFi and Ethernet -- I have
static IP and when I plug into wire -- I have wired setup, when
I am unplugged -- WiFi works here.  But the magic of switching
is inside if_lagg, not in some external app that looks for events
and does the plumbing.  And I like this way of doing things.

 How other UNIX-like OS-es solve this?

Looks like OSX does have the smart client that polls for the
interface events and configures network accordingly.  I should
dig it a bit more, since I hadn't touched this part of OSX yet.
-- 
Eygene Ryabinkin,,,^..^,,,
[ Life's unfair - but root password helps!   | codelabs.ru ]
[ 82FE 06BC D497 C0DE 49EC  4FF0 16AF 9EAE 8152 ECFB | freebsd.org ]


pgp4IumHasqI6.pgp
Description: PGP signature