Re: Impossible to turn BROADCAST mode off on ethernet device?

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Mon May 19 2003 - 13:18:04 EST


On Mon, 19 May 2003, Denis Zaitsev wrote:

> Kernel 2.4.20. I do:
>
> ifconfig eth0 -broadcast
>
> And BROADCAST isn't turned off... The ethernet modules are: eepro100,
> tulip, 3c59x. So, what does it mean?
>
> Thanks in advance.

Your `ifconfig` might not allow broadcast to be turned off as
long a eth0 is `up`. So I just made a little program to get the flags,
and reset the flags. This shows that your observation is, indeed,
correct.

If you mess around with this, I think you will find that you can't
set broadcast OFF as long at the IFF_UP flag is set. This may be
the required behavior because an interface without broadcast
capability will not work on ethernet because ARP requires it.

#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <string.h>
#include <net/if.h>

int main()
{
    struct ifreq ifr;
    int s, status;
    if((s = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP)) == -1)
    {
        fprintf(stderr, "socket() failed (%s)\n", strerror(errno));
        return s;
    }
    memset(&ifr, 0x00, sizeof(ifr));
    ifr.ifr_netmask.sa_family = AF_INET;
    strcpy(ifr.ifr_name, "eth0");
    status = ioctl(s, SIOCGIFFLAGS, &ifr);
    ifr.ifr_flags &= ~IFF_BROADCAST;
    status = ioctl(s, SIOCGIFFLAGS, &ifr);

    (void)close(s);
    return status;
}

Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri May 23 2003 - 22:00:35 EST