svn commit: r191651 - head/usr.sbin/mtest
John Baldwin
jhb at freebsd.org
Wed Feb 16 14:01:22 UTC 2011
On Wednesday, February 16, 2011 7:13:42 am Bruce Simpson wrote:
> John,
>
> That's news to me. I'm pretty sure I tested this code with and without
> INET6 when I checked it in, given I was mostly testing without INET6.
>
> This was a very long time ago, so I was surprised to receive your
> message. Could something have changed to have broken mtest?
I think the code was always busted (and I just tried to use mtest on 8 for the
first time today with a kernel that had INET6 compiled out):
int
main(int argc, char **argv)
{
char line[LINE_LENGTH];
char *p;
int i, s, s6;
s = -1;
s6 = -1;
#ifdef INET
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (s == -1)
err(1, "can't open IPv4 socket");
#endif
#ifdef INET6
s6 = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
if (s6 == -1)
err(1, "can't open IPv6 socket");
#endif
With INET6 enabled in userland but a kernel not built with INET6, then the
call to socket() for s6 will fail causing it to exit right away. Presumably
the code should be changed to do something more like:
#ifdef INET
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
#else
s = -1;
#endif
#ifdef INET6
s6 = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
#else
s6 = -1;
#endif
if (s < 0 && s6 < 0)
err(1, "can't open socket");
However, the rest of the code in mtest needs to be updated as well to not
assume that 's' and 's6' are always valid so it would be a fair amount of
work.
> thanks
> BMS
>
> John Baldwin wrote:
> > On Wednesday, April 29, 2009 5:50:04 am Bruce M Simpson wrote:
> >> Author: bms
> >> Date: Wed Apr 29 09:50:04 2009
> >> New Revision: 191651
> >> URL: http://svn.freebsd.org/changeset/base/191651
> >>
> >> Log:
> >> Merge IPv6-capable mtest(8) from MLDv2 branch.
> >>
> >> Modified:
> >> head/usr.sbin/mtest/Makefile
> >> head/usr.sbin/mtest/mtest.8
> >> head/usr.sbin/mtest/mtest.c
> >
> > This is completely broken as it fails to work if you don't have INET6
compiled
> > into the kernel, even if all you want to do is test joining IPv4 multicast
> > groups.
> >
>
--
John Baldwin
More information about the svn-src-all
mailing list