1. 20 Feb, 2019 2 commits
    • Hauke Mehrtens's avatar
      uapi/if_ether.h: move __UAPI_DEF_ETHHDR libc define · cb4f43bf
      Hauke Mehrtens authored
      commit da360299 upstream.
      This fixes a compile problem of some user space applications by not
      including linux/libc-compat.h in uapi/if_ether.h.
      linux/libc-compat.h checks which "features" the header files, included
      from the libc, provide to make the Linux kernel uapi header files only
      provide no conflicting structures and enums. If a user application mixes
      kernel headers and libc headers it could happen that linux/libc-compat.h
      gets included too early where not all other libc headers are included
      yet. Then the linux/libc-compat.h would not prevent all the
      redefinitions and we run into compile problems.
      This patch removes the include of linux/libc-compat.h from
      uapi/if_ether.h to fix the recently introduced case, but not all as this
      is more or less impossible.
      It is no problem to do the check directly in the if_ether.h file and not
      in libc-compat.h as this does not need any fancy glibc header detection
      as glibc never provided struct ethhdr and should define
      __UAPI_DEF_ETHHDR by them self when they will provide this.
      The following test program did not compile correctly any more:
      #include <linux/if_ether.h>
      #include <netinet/in.h>
      #include <linux/in.h>
      int main(void)
      	return 0;
      Fixes: 6926e041
       ("uapi/if_ether.h: prevent redefinition of struct ethhdr")
      Reported-by: default avatarGuillaume Nault <g.nault@alphalink.fr>
      Cc: <stable@vger.kernel.org> # 4.15
      Signed-off-by: default avatarHauke Mehrtens <hauke@hauke-m.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    • Hauke Mehrtens's avatar
      uapi/if_ether.h: prevent redefinition of struct ethhdr · 28b5d0be
      Hauke Mehrtens authored
      commit 6926e041
      Musl provides its own ethhdr struct definition. Add a guard to prevent
      its definition of the appropriate musl header has already been included.
      glibc does not implement this header, but when glibc will implement this
      they can just define __UAPI_DEF_ETHHDR 0 to make it work with the
      Signed-off-by: default avatarHauke Mehrtens <hauke@hauke-m.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
  2. 30 May, 2018 1 commit
    • Toshiaki Makita's avatar
      net: Fix vlan untag for bridge and vlan_dev with reorder_hdr off · f5e863e5
      Toshiaki Makita authored
      [ Upstream commit 4bbb3e0e8239f9079bf1fe20b3c0cb598714ae61 ]
      When we have a bridge with vlan_filtering on and a vlan device on top of
      it, packets would be corrupted in skb_vlan_untag() called from
      The problem sits in skb_reorder_vlan_header() used in skb_vlan_untag(),
      which makes use of skb->mac_len. In this function mac_len is meant for
      handling rx path with vlan devices with reorder_header disabled, but in
      tx path mac_len is typically 0 and cannot be used, which is the problem
      in this case.
      The current code even does not properly handle rx path (skb_vlan_untag()
      called from __netif_receive_skb_core()) with reorder_header off actually.
      In rx path single tag case, it works as follows:
      - Before skb_reorder_vlan_header()
       mac_header                                data
         v                                        v
         |        ETH        |    VLAN     | ETH  |
         |       ADDRS       | TPID | TCI  | TYPE |
         <-------- mac_len --------->
                              to be removed
      - After skb_reorder_vlan_header()
                  mac_header                     data
                       v                          v
                       |        ETH        | ETH  |
                       |       ADDRS       | TYPE |
                       <-------- mac_len --------->
      This is ok, but in rx double tag case, it corrupts packets:
      - Before skb_reorder_vlan_header()
       mac_header                                              data
         v                                                      v
         |        ETH        |    VLAN     |    VLAN     | ETH  |
         |       ADDRS       | TPID | TCI  | TPID | TCI  | TYPE |
         <--------------- mac_len ---------------->
                                          should be removed
                               actually will be removed
      - After skb_reorder_vlan_header()
                  mac_header                                   data
                       v                                        v
                                     |        ETH        | ETH  |
                                     |       ADDRS       | TYPE |
                       <--------------- mac_len ---------------->
      So, two of vlan tags are both removed while only inner one should be
      removed and mac_header (and mac_len) is broken.
      skb_vlan_untag() is meant for removing the vlan header at (skb->data - 2),
      so use skb->data and skb->mac_header to calculate the right offset.
      Reported-by: default avatarBrandon Carpenter <brandon.carpenter@cypherpath.com>
      Fixes: a6e18ff1
       ("vlan: Fix untag operations of stacked vlans with REORDER_HEADER off")
      Signed-off-by: default avatarToshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
  3. 10 Sep, 2015 1 commit
  4. 28 Aug, 2014 1 commit
    • Florian Fainelli's avatar
      net: dsa: reduce number of protocol hooks · 3e8a72d1
      Florian Fainelli authored
      DSA is currently registering one packet_type function per EtherType it
      needs to intercept in the receive path of a DSA-enabled Ethernet device.
      Right now we have three of them: trailer, DSA and eDSA, and there might
      be more in the future, this will not scale to the addition of new
      This patch proceeds with adding a new layer of abstraction and two new
      dsa_switch_rcv() which will dispatch into the tag-protocol specific
      receive function implemented by net/dsa/tag_*.c
      dsa_slave_xmit() which will dispatch into the tag-protocol specific
      transmit function implemented by net/dsa/tag_*.c
      When we do create the per-port slave network devices, we iterate over
      the switch protocol to assign the DSA-specific receive and transmit
      A new fake ethertype value is used: ETH_P_XDSA to illustrate the fact
      that this is no longer going to look like ETH_P_DSA or ETH_P_TRAILER
      like it used to be.
      This allows us to greatly simplify the check in eth_type_trans() and
      always override the skb->protocol with ETH_P_XDSA for Ethernet switches
      tagged protocol, while also reducing the number repetitive slave
      netdevice_ops assignments.
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  5. 15 Mar, 2014 1 commit
  6. 04 Mar, 2014 1 commit
  7. 26 Feb, 2014 1 commit
  8. 04 Nov, 2013 1 commit
    • Arvid Brodin's avatar
      net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0) · f421436a
      Arvid Brodin authored
      High-availability Seamless Redundancy ("HSR") provides instant failover
      redundancy for Ethernet networks. It requires a special network topology where
      all nodes are connected in a ring (each node having two physical network
      interfaces). It is suited for applications that demand high availability and
      very short reaction time.
      HSR acts on the Ethernet layer, using a registered Ethernet protocol type to
      send special HSR frames in both directions over the ring. The driver creates
      virtual network interfaces that can be used just like any ordinary Linux
      network interface, for IP/TCP/UDP traffic etc. All nodes in the network ring
      must be HSR capable.
      This code is a "best effort" to comply with the HSR standard as described in
      IEC 62439-3:2010 (HSRv0).
      Signed-off-by: default avatarArvid Brodin <arvid.brodin@xdin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  9. 28 Mar, 2013 1 commit
    • Simon Horman's avatar
      net: add ETH_P_802_3_MIN · e5c5d22e
      Simon Horman authored
      Add a new constant ETH_P_802_3_MIN, the minimum ethernet type for
      an 802.3 frame. Frames with a lower value in the ethernet type field
      are Ethernet II.
      Also update all the users of this value that David Miller and
      I could find to use the new constant.
      Also correct a bug in util.c. The comparison with ETH_P_802_3_MIN
      should be >= not >.
      As suggested by Jesse Gross.
      Compile tested only.
      Cc: David Miller <davem@davemloft.net>
      Cc: Jesse Gross <jesse@nicira.com>
      Cc: Karsten Keil <isdn@linux-pingi.de>
      Cc: John W. Linville <linville@tuxdriver.com>
      Cc: Johannes Berg <johannes@sipsolutions.net>
      Cc: Bart De Schuymer <bart.de.schuymer@pandora.be>
      Cc: Stephen Hemminger <stephen@networkplumber.org>
      Cc: Patrick McHardy <kaber@trash.net>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Cc: Gustavo Padovan <gustavo@padovan.org>
      Cc: Johan Hedberg <johan.hedberg@gmail.com>
      Cc: linux-bluetooth@vger.kernel.org
      Cc: netfilter-devel@vger.kernel.org
      Cc: bridge@lists.linux-foundation.org
      Cc: linux-wireless@vger.kernel.org
      Cc: linux1394-devel@lists.sourceforge.net
      Cc: linux-media@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Cc: dev@openvswitch.org
      Acked-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
      Acked-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  10. 11 Feb, 2013 1 commit
  11. 03 Nov, 2012 1 commit
  12. 13 Oct, 2012 1 commit
  13. 19 Jun, 2012 1 commit
  14. 05 Dec, 2011 1 commit
  15. 30 Sep, 2011 1 commit
    • Arik Nemtsov's avatar
      mac80211: handle TDLS high-level commands and frames · dfe018bf
      Arik Nemtsov authored
      Register and implement the TDLS cfg80211 callback functions.
      Internally prepare and send TDLS management frames. We incorporate
      local STA capabilities and supported rates with extra IEs given by
      usermode. The resulting packet is either encapsulated in a data frame,
      or assembled as an action frame. It is transmitted either directly or
      through the AP, as mandated by the TDLS specification.
      Declare support for the TDLS external setup wiphy capability. This
      tells usermode to handle link setup and discovery on its own, and use the
      kernel driver for sending TDLS mgmt packets.
      Signed-off-by: default avatarArik Nemtsov <arik@wizery.com>
      Cc: Kalyan C Gaddam <chakkal@iit.edu>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
  16. 13 Aug, 2011 1 commit
  17. 17 Jul, 2011 1 commit
  18. 27 May, 2011 1 commit
  19. 09 May, 2011 1 commit
    • Alexey Dobriyan's avatar
      net: add mac_pton() for parsing MAC address · 4940fc88
      Alexey Dobriyan authored
      mac_pton() parses MAC address in form XX:XX:XX:XX:XX:XX and only in that form.
      mac_pton() doesn't dirty result until it's sure string representation is valid.
      mac_pton() doesn't care about characters _after_ last octet,
      it's up to caller to deal with it.
      mac_pton() diverges from 0/-E return value convention.
      Target usage:
      	if (!mac_pton(str, whatever->mac))
      		return -EINVAL;
      	/* ->mac being u8 [ETH_ALEN] is filled at this point. */
      	/* optionally check str[3 * ETH_ALEN - 1] for termination */
      Use mac_pton() in pktgen and netconsole for start.
      Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  20. 06 Jan, 2011 1 commit
  21. 24 Aug, 2010 1 commit
  22. 23 Aug, 2010 1 commit
  23. 03 Jun, 2010 1 commit
  24. 31 Mar, 2010 1 commit
  25. 09 Dec, 2009 1 commit
  26. 16 Nov, 2009 1 commit
  27. 27 Jul, 2009 1 commit
  28. 02 Jul, 2009 1 commit
  29. 09 Jun, 2009 1 commit
  30. 08 Jun, 2009 1 commit
  31. 13 Mar, 2009 1 commit
  32. 06 Feb, 2009 1 commit
  33. 14 Oct, 2008 1 commit
  34. 09 Oct, 2008 4 commits
    • Herbert Xu's avatar
      gre: Add Transparent Ethernet Bridging · e1a80002
      Herbert Xu authored
      This patch adds support for Ethernet over GRE encapsulation.
      This is exposed to user-space with a new link type of "gretap"
      instead of "gre".  It will create an ARPHRD_ETHER device in
      lieu of the usual ARPHRD_IPGRE.
      Note that to preserver backwards compatibility all Transparent
      Ethernet Bridging packets are passed to an ARPHRD_IPGRE tunnel
      if its key matches and there is no ARPHRD_ETHER device whose
      key matches more closely.
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    • Lennert Buytenhek's avatar
      dsa: add support for Trailer tagging format · 396138f0
      Lennert Buytenhek authored
      This adds support for the Trailer switch tagging format.  This is
      another tagging that doesn't explicitly mark tagged packets with a
      distinct ethertype, so that we need to add a similar hack in the
      receive path as for the Original DSA tagging format.
      Signed-off-by: default avatarLennert Buytenhek <buytenh@marvell.com>
      Tested-by: default avatarByron Bradley <byron.bbradley@gmail.com>
      Tested-by: default avatarTim Ellis <tim.ellis@mac.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    • Lennert Buytenhek's avatar
      dsa: add support for original DSA tagging format · cf85d08f
      Lennert Buytenhek authored
      Most of the DSA switches currently in the field do not support the
      Ethertype DSA tagging format that one of the previous patches added
      support for, but only the original DSA tagging format.
      The original DSA tagging format carries the same information as the
      Ethertype DSA tagging format, but with the difference that it does not
      have an ethertype field.  In other words, when receiving a packet that
      is tagged with an original DSA tag, there is no way of telling in
      eth_type_trans() that this packet is in fact a DSA-tagged packet.
      This patch adds a hook into eth_type_trans() which is only compiled in
      if support for a switch chip that doesn't support Ethertype DSA is
      selected, and which checks whether there is a DSA switch driver
      instance attached to this network device which uses the old tag format.
      If so, it sets the protocol field to ETH_P_DSA without looking at the
      packet, so that the packet ends up in the right place.
      Signed-off-by: default avatarLennert Buytenhek <buytenh@marvell.com>
      Tested-by: default avatarNicolas Pitre <nico@marvell.com>
      Tested-by: default avatarPeter van Valderen <linux@ddcrew.com>
      Tested-by: default avatarDirk Teurlings <dirk@upexia.nl>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    • Lennert Buytenhek's avatar
      net: Distributed Switch Architecture protocol support · 91da11f8
      Lennert Buytenhek authored
      Distributed Switch Architecture is a protocol for managing hardware
      switch chips.  It consists of a set of MII management registers and
      commands to configure the switch, and an ethernet header format to
      signal which of the ports of the switch a packet was received from
      or is intended to be sent to.
      The switches that this driver supports are typically embedded in
      access points and routers, and a typical setup with a DSA switch
      looks something like this:
      	+-----------+       +-----------+
      	|           | RGMII |           |
      	|           +-------+           +------ 1000baseT MDI ("WAN")
      	|           |       |  6-port   +------ 1000baseT MDI ("LAN1")
      	|    CPU    |       |  ethernet +------ 1000baseT MDI ("LAN2")
      	|           |MIImgmt|  switch   +------ 1000baseT MDI ("LAN3")
      	|           +-------+  w/5 PHYs +------ 1000baseT MDI ("LAN4")
      	|           |       |           |
      	+-----------+       +-----------+
      The switch driver presents each port on the switch as a separate
      network interface to Linux, polls the switch to maintain software
      link state of those ports, forwards MII management interface
      accesses to those network interfaces (e.g. as done by ethtool) to
      the switch, and exposes the switch's hardware statistics counters
      via the appropriate Linux kernel interfaces.
      This initial patch supports the MII management interface register
      layout of the Marvell 88E6123, 88E6161 and 88E6165 switch chips, and
      supports the "Ethertype DSA" packet tagging format.
      (There is no officially registered ethertype for the Ethertype DSA
      packet format, so we just grab a random one.  The ethertype to use
      is programmed into the switch, and the switch driver uses the value
      of ETH_P_EDSA for this, so this define can be changed at any time in
      the future if the one we chose is allocated to another protocol or
      if Ethertype DSA gets its own officially registered ethertype, and
      everything will continue to work.)
      Signed-off-by: default avatarLennert Buytenhek <buytenh@marvell.com>
      Tested-by: default avatarNicolas Pitre <nico@marvell.com>
      Tested-by: default avatarByron Bradley <byron.bbradley@gmail.com>
      Tested-by: default avatarTim Ellis <tim.ellis@mac.com>
      Tested-by: default avatarPeter van Valderen <linux@ddcrew.com>
      Tested-by: default avatarDirk Teurlings <dirk@upexia.nl>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  35. 23 Sep, 2008 1 commit
  36. 22 Aug, 2008 1 commit