tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

if_vlan extra padding



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);


Home | Main Index | Thread Index | Old Index