Bug 162028 - [ixgbe] [patch] misplaced #endif in ixgbe.c
Summary: [ixgbe] [patch] misplaced #endif in ixgbe.c
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 7.4-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Eric Joyner
URL:
Keywords: IntelNetworking
Depends on:
Blocks:
 
Reported: 2011-10-26 12:00 UTC by hoomanfazaeli
Modified: 2015-09-04 15:35 UTC (History)
2 users (show)

See Also:


Attachments
file.diff (371 bytes, patch)
2011-10-26 12:00 UTC, hoomanfazaeli
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description hoomanfazaeli 2011-10-26 12:00:20 UTC
A misplaced #endif in ixgbe_ioctl() causes interface MTU to become
zero when INET and INET6 are undefined.

Fix: Patch attached with submission follows:
How-To-Repeat: See sys/dev/ixgbe/ixgbe.c v 1.53 
function ixgbe_ioctl.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2011-10-29 13:13:14 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-net

Over to maintainer(s).
Comment 2 pluknet 2011-10-29 13:58:09 UTC
I have a more complete patch. Can you test it please?

Index: sys/dev/ixgbe/ixgbe.c
===================================================================
--- sys/dev/ixgbe/ixgbe.c       (revision 226068)
+++ sys/dev/ixgbe/ixgbe.c       (working copy)
@@ -867,16 +867,15 @@ static int
 ixgbe_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
 {
        struct adapter  *adapter = ifp->if_softc;
-       struct ifreq    *ifr = (struct ifreq *) data;
+       struct ifreq    *ifr = (struct ifreq *)data;
 #if defined(INET) || defined(INET6)
-       struct ifaddr *ifa = (struct ifaddr *)data;
-       bool            avoid_reset = FALSE;
+       struct ifaddr   *ifa = (struct ifaddr *)data;
 #endif
-       int             error = 0;
+       bool            avoid_reset = FALSE;
+       int             error = 0;

        switch (command) {
-
-        case SIOCSIFADDR:
+       case SIOCSIFADDR:
 #ifdef INET
                if (ifa->ifa_addr->sa_family == AF_INET)
                        avoid_reset = TRUE;
@@ -885,7 +884,6 @@ ixgbe_ioctl(struct ifnet * ifp, u_long command, ca
                if (ifa->ifa_addr->sa_family == AF_INET6)
                        avoid_reset = TRUE;
 #endif
-#if defined(INET) || defined(INET6)
                /*
                ** Calling init results in link renegotiation,
                ** so we avoid doing it when possible.
@@ -894,12 +892,13 @@ ixgbe_ioctl(struct ifnet * ifp, u_long command, ca
                        ifp->if_flags |= IFF_UP;
                        if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
                                ixgbe_init(adapter);
+#ifdef INET
                        if (!(ifp->if_flags & IFF_NOARP))
                                arp_ifinit(ifp, ifa);
+#endif
                } else
                        error = ether_ioctl(ifp, command, data);
                break;
-#endif
        case SIOCSIFMTU:
                IOCTL_DEBUGOUT("ioctl: SIOCSIFMTU (Set Interface MTU)");
                if (ifr->ifr_mtu > IXGBE_MAX_FRAME_SIZE - ETHER_HDR_LEN) {


-- 
wbr,
pluknet
Comment 3 hoomanfazaeli 2011-10-30 07:33:44 UTC
On 10/29/2011 4:28 PM, Sergey Kandaurov wrote:
> I have a more complete patch. Can you test it please?
>
> Index: sys/dev/ixgbe/ixgbe.c
> ===================================================================
> --- sys/dev/ixgbe/ixgbe.c       (revision 226068)
> +++ sys/dev/ixgbe/ixgbe.c       (working copy)
> @@ -867,16 +867,15 @@ static int
>   ixgbe_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
>   {
>          struct adapter  *adapter = ifp->if_softc;
> -       struct ifreq    *ifr = (struct ifreq *) data;
> +       struct ifreq    *ifr = (struct ifreq *)data;
>   #if defined(INET) || defined(INET6)
> -       struct ifaddr *ifa = (struct ifaddr *)data;
> -       bool            avoid_reset = FALSE;
> +       struct ifaddr   *ifa = (struct ifaddr *)data;
>   #endif
> -       int             error = 0;
> +       bool            avoid_reset = FALSE;
> +       int             error = 0;
>
>          switch (command) {
> -
> -        case SIOCSIFADDR:
> +       case SIOCSIFADDR:
>   #ifdef INET
>                  if (ifa->ifa_addr->sa_family == AF_INET)
>                          avoid_reset = TRUE;
> @@ -885,7 +884,6 @@ ixgbe_ioctl(struct ifnet * ifp, u_long command, ca
>                  if (ifa->ifa_addr->sa_family == AF_INET6)
>                          avoid_reset = TRUE;
>   #endif
> -#if defined(INET) || defined(INET6)
>                  /*
>                  ** Calling init results in link renegotiation,
>                  ** so we avoid doing it when possible.
> @@ -894,12 +892,13 @@ ixgbe_ioctl(struct ifnet * ifp, u_long command, ca
>                          ifp->if_flags |= IFF_UP;
>                          if (!(ifp->if_drv_flags&  IFF_DRV_RUNNING))
>                                  ixgbe_init(adapter);
> +#ifdef INET
>                          if (!(ifp->if_flags&  IFF_NOARP))
>                                  arp_ifinit(ifp, ifa);
> +#endif
>                  } else
>                          error = ether_ioctl(ifp, command, data);
>                  break;
> -#endif
>          case SIOCSIFMTU:
>                  IOCTL_DEBUGOUT("ioctl: SIOCSIFMTU (Set Interface MTU)");
>                  if (ifr->ifr_mtu>  IXGBE_MAX_FRAME_SIZE - ETHER_HDR_LEN) {
>
>
sure.
I am very busy right now.
Will test as soon as I can.
Comment 4 Sean Bruno freebsd_committer freebsd_triage 2015-06-30 17:51:52 UTC
This is now applicable to if_ix.c but seems to still be applicable.
Comment 5 Sean Bruno freebsd_committer freebsd_triage 2015-07-24 15:26:55 UTC
Regenerated patch after ixgbe(4) overhaul.

https://reviews.freebsd.org/D3187
Comment 6 commit-hook freebsd_committer freebsd_triage 2015-08-03 16:39:44 UTC
A commit references this bug:

Author: sbruno
Date: Mon Aug  3 16:39:26 UTC 2015
New revision: 286238
URL: https://svnweb.freebsd.org/changeset/base/286238

Log:
  A misplaced #endif in ixgbe_ioctl() causes interface MTU to become
  zero when INET and INET6 are undefined.

  PR:		162028
  Differential Revision:	https://reviews.freebsd.org/D3187
  Submitted by:	hoomanfazaeli@gmail.com pluknet
  Reviewed by:	erj hiren gelbius
  MFC after:	2 weeks

Changes:
  head/sys/dev/ixgbe/if_ix.c
Comment 7 commit-hook freebsd_committer freebsd_triage 2015-09-04 15:35:02 UTC
A commit references this bug:

Author: sbruno
Date: Fri Sep  4 15:34:27 UTC 2015
New revision: 287461
URL: https://svnweb.freebsd.org/changeset/base/287461

Log:
  MFC r286238

  A misplaced #endif in ixgbe_ioctl() causes interface MTU to become
  zero when INET and INET6 are undefined.

  PR:		162028
  Submitted by:	hoomanfazaeli@gmail.com pluknet

Changes:
_U  stable/10/
  stable/10/sys/dev/ixgbe/if_ix.c