From 6f135a7584d9cba78aab7bd3b810d5f29e39b53d Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Sun, 15 May 2011 12:51:00 +0000 Subject: [PATCH] When setting media always and not just in case of switching to IFM_AUTO clear the options of the current media, i.e. only inherit the instance, which matches what NetBSD does. Without this it's really non-intuitive that the following sequence: ifconfig bge0 media 1000baseT mediaopt full-duplex ifconfig bge0 media 100baseTX results in 100baseTX full-duplex to be set or that: ifconfig bge0 media autoselect mediaopt flowcontrol ifconfig bge0 media 1000baseT mediaopt full-duplex tries to set 1000baseT full-duplex with flowcontrol, which isn't suported und thus fails while the following: ifconfig re0 media 1000baseT mediaopt flowcontrol,full-duplex ifconfig re0 media autoselect just switches to autoselection without flowcontrol. MFC after: 2 weeks --- sbin/ifconfig/ifmedia.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c index 0fd2f2b3dee2..0b0daa3086a1 100644 --- a/sbin/ifconfig/ifmedia.c +++ b/sbin/ifconfig/ifmedia.c @@ -268,13 +268,9 @@ setmedia(const char *val, int d, int s, const struct afswtch *afp) subtype = get_media_subtype(IFM_TYPE(ifmr->ifm_ulist[0]), val); strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - ifr.ifr_media = (ifmr->ifm_current & ~(IFM_NMASK|IFM_TMASK)) | + ifr.ifr_media = (ifmr->ifm_current & IFM_IMASK) | IFM_TYPE(ifmr->ifm_ulist[0]) | subtype; - if ((ifr.ifr_media & IFM_TMASK) == 0) { - ifr.ifr_media &= ~(IFM_GMASK | IFM_OMASK); - } - ifmr->ifm_current = ifr.ifr_media; callback_register(setifmediacallback, (void *)ifmr); }