Skip to contentSkip to conversation

Make ARP replies at least 64 bytes long

PATCH Applied Hervé Poussineau 4 participants 4 messages Sep 15, 2010 – Sep 20, 2010

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Make ARP replies at least 64 bytes long

IEEE 802.3 standard requires Ethernet frames to be at least 64 bytes long.
If it is not the case, they will be considered as runt frames, and may be ignored by netcard and/or OS

---
 slirp/slirp.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
slirp/slirp.c +2 -1
index 82fd9b4..332d83b 100644
@@ -599,7 +599,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
 {
     struct ethhdr *eh = (struct ethhdr *)pkt;
     struct arphdr *ah = (struct arphdr *)(pkt + ETH_HLEN);
-    uint8_t arp_reply[ETH_HLEN + sizeof(struct arphdr)];
+    uint8_t arp_reply[max(ETH_HLEN + sizeof(struct arphdr), 64)];
     struct ethhdr *reh = (struct ethhdr *)arp_reply;
     struct arphdr *rah = (struct arphdr *)(arp_reply + ETH_HLEN);
     int ar_op;
@@ -619,6 +619,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
             }
             return;
         arp_ok:
+            memset(arp_reply, 0, sizeof(arp_reply));
             /* XXX: make an ARP request to have the client address */
             memcpy(slirp->client_ethaddr, eh->h_source, ETH_ALEN);
 
Signature · 1 line
1.7.1.GIT
#1 lore raw
Quoted 4 lines · Hervé Poussineau

IEEE 802.3 standard requires Ethernet frames to be at least 64 bytes long.
If it is not the case, they will be considered as runt frames, and may be ignored by netcard and/or OS

Applied, thanks.

Quoted 29 lines
---
 slirp/slirp.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
slirp/slirp.c +2 -1
index 82fd9b4..332d83b 100644
@@ -599,7 +599,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
 {
     struct ethhdr *eh = (struct ethhdr *)pkt;
     struct arphdr *ah = (struct arphdr *)(pkt + ETH_HLEN);
-    uint8_t arp_reply[ETH_HLEN + sizeof(struct arphdr)];
+    uint8_t arp_reply[max(ETH_HLEN + sizeof(struct arphdr), 64)];
     struct ethhdr *reh = (struct ethhdr *)arp_reply;
     struct arphdr *rah = (struct arphdr *)(arp_reply + ETH_HLEN);
     int ar_op;
@@ -619,6 +619,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
             }
             return;
         arp_ok:
+            memset(arp_reply, 0, sizeof(arp_reply));
             /* XXX: make an ARP request to have the client address */
             memcpy(slirp->client_ethaddr, eh->h_source, ETH_ALEN);
 
Signature · 1 line
1.7.1.GIT
#2 lore raw
In reply to Hervé Poussineau
Quoted 4 lines · Hervé Poussineau

IEEE 802.3 standard requires Ethernet frames to be at least 64 bytes long.
If it is not the case, they will be considered as runt frames, and may be ignored by netcard and/or OS

IMO slirp is not the best place for this, e.g. virtio-net does not need the padding.

Quoted 28 lines
---
 slirp/slirp.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
slirp/slirp.c +2 -1
index 82fd9b4..332d83b 100644
@@ -599,7 +599,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
 {
     struct ethhdr *eh = (struct ethhdr *)pkt;
     struct arphdr *ah = (struct arphdr *)(pkt + ETH_HLEN);
-    uint8_t arp_reply[ETH_HLEN + sizeof(struct arphdr)];
+    uint8_t arp_reply[max(ETH_HLEN + sizeof(struct arphdr), 64)];
     struct ethhdr *reh = (struct ethhdr *)arp_reply;
     struct arphdr *rah = (struct arphdr *)(arp_reply + ETH_HLEN);
     int ar_op;
@@ -619,6 +619,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
             }
             return;
         arp_ok:
+            memset(arp_reply, 0, sizeof(arp_reply));
             /* XXX: make an ARP request to have the client address */
             memcpy(slirp->client_ethaddr, eh->h_source, ETH_ALEN);
 
Signature · 1 line
1.7.1.GIT
#3 lore raw
Quoted 8 lines · Michael S. Tsirkin
Quoted 4 lines · Hervé Poussineau

IEEE 802.3 standard requires Ethernet frames to be at least 64 bytes long.
If it is not the case, they will be considered as runt frames, and may be ignored by netcard and/or OS

IMO slirp is not the best place for this, e.g. virtio-net does not need the padding.

I don't think it matters if virtio-net needs it or net; slirp should comply to RFC and standards, so it should make frames the correct size.

Paolo