[prev in list] [next in list] [prev in thread] [next in thread] 

List:       netbsd-tech-net
Subject:    if_vlan extra padding
From:       Ryota Ozaki <ozaki-r () netbsd ! org>
Date:       2015-03-02 9:05:36
Message-ID: CAKrYomjbL9fT7=oxK=voOqz6vk+9N5_z_y-fDWLnUaiw_29nyw () mail ! gmail ! com
[Download RAW message or body]

Hi,

We found extra frame padding in vlan(4).

http://nxr.netbsd.org/xref/src/sys/net/if_vlan.c#808

Here vlan pads a frame with zeros up to 68 bytes
(ETHER_MIN_LEN + ETHER_VLAN_ENCAP_LEN). It expects
that if the frame is untagged, it keeps 64 bytes
at least. However, it lacks concern about CRC
(4 bytes). So a sending frame will be 68 + 4 = 72 bytes.

Our fix pads up to 64 bytes like the below patch.
How about the fix? Any comments?

FYI FreeBSD also pads up to 64 bytes:
http://nxr.netbsd.org/xref/src-freebsd/sys/net/if_vlan.c#1066
(it pads before tagging though.)

  ozaki-r

diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index 2d5b861..02b6686 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -806,9 +806,10 @@ vlan_start(struct ifnet *ifp)
                                 * after deleting a tag.
                                 */
                                if (m->m_pkthdr.len <
-                                   (ETHER_MIN_LEN + ETHER_VLAN_ENCAP_LEN)) {
+                                   (ETHER_MIN_LEN - ETHER_CRC_LEN +
+                                    ETHER_VLAN_ENCAP_LEN)) {
                                        m_copyback(m, m->m_pkthdr.len,
-                                           (ETHER_MIN_LEN +
+                                           (ETHER_MIN_LEN - ETHER_CRC_LEN +
                                             ETHER_VLAN_ENCAP_LEN) -
                                             m->m_pkthdr.len,
                                            vlan_zero_pad_buff);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic