[PATCH] ping.c : fix min/max packet size usage
Florian Fainelli
florian at alphacore.net
Sat Mar 10 14:12:46 UTC 2007
Hi Denis,
I agree with you, if you don't want to introduce a regression, either you have
to redefine the max ICMP packet size, which is currently defined as 76, or
you don't even check for max size if you prefer. I saw you now check for a
valid packet size in order to unpack it.
Here is the diff against latest revision, because datalen is initialised to
DEFDATALEN if you do not specify the packet size.
Index: networking/ping.c
===================================================================
--- networking/ping.c (révision 18060)
+++ networking/ping.c (copie de travail)
@@ -91,7 +91,7 @@
struct sockaddr_in pingaddr;
struct icmp *pkt;
int pingsock, c;
- char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN];
+ char packet[datalen + MAXIPLEN + MAXICMPLEN];
pingsock = create_icmp_socket();
pingaddr = lsa->sin;
@@ -101,7 +101,7 @@
pkt->icmp_type = ICMP_ECHO;
pkt->icmp_cksum = in_cksum((unsigned short *) pkt, sizeof(packet));
- c = sendto(pingsock, packet, DEFDATALEN + ICMP_MINLEN, 0,
+ c = sendto(pingsock, packet, datalen + ICMP_MINLEN, 0,
(struct sockaddr *) &pingaddr, sizeof(pingaddr));
if (c < 0) {
Le samedi 3 mars 2007, Denis Vlasenko a écrit :
> On Friday 02 March 2007 01:30, Jason Schoon wrote:
> > > Unfortunately, it introduces a regression:
> > >
> > > unpatched:
> > >
> > > # ./busybox ping -s 1000 127.0.0.1
> > > PING 127.0.0.1 (127.0.0.1): 1000 data bytes
> > > 1008 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.0 ms
> > > 1008 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.0 ms
> > > 1008 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.0 ms
> > > 1008 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.0 ms
> > >
> > > patched:
> > >
> > > # ./busybox ping -s 1000 127.0.0.1
> > > PING 127.0.0.1 (127.0.0.1): 1000 data bytes
> > > ^C
> > > --- 127.0.0.1 ping statistics ---
> > > 4 packets transmitted, 0 packets received, 100% packet loss
> >
> > Agreed, I saw similar behavior using the original patch against 1.2.2.1.
>
> Try revision 17999 (or current svn).
> --
> vda
--
Cordialement, Florian
---------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20070310/b456e194/attachment-0002.pgp
More information about the busybox
mailing list