udhcpc: don't use BPF filter, users report problems (bugs 4598, 6746)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
fe8390e0fe
commit
e4785ca653
@ -976,9 +976,20 @@ static int udhcp_raw_socket(int ifindex)
|
|||||||
int fd;
|
int fd;
|
||||||
struct sockaddr_ll sock;
|
struct sockaddr_ll sock;
|
||||||
|
|
||||||
|
log1("Opening raw socket on ifindex %d", ifindex); //log2?
|
||||||
|
|
||||||
|
fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
|
||||||
|
log1("Got raw socket fd"); //log2?
|
||||||
|
|
||||||
|
sock.sll_family = AF_PACKET;
|
||||||
|
sock.sll_protocol = htons(ETH_P_IP);
|
||||||
|
sock.sll_ifindex = ifindex;
|
||||||
|
xbind(fd, (struct sockaddr *) &sock, sizeof(sock));
|
||||||
|
|
||||||
|
#if 0 /* Several users reported breakage when BPF filter is used */
|
||||||
|
if (CLIENT_PORT == 68) {
|
||||||
|
/* Use only if standard port is in use */
|
||||||
/*
|
/*
|
||||||
* Comment:
|
|
||||||
*
|
|
||||||
* I've selected not to see LL header, so BPF doesn't see it, too.
|
* I've selected not to see LL header, so BPF doesn't see it, too.
|
||||||
* The filter may also pass non-IP and non-ARP packets, but we do
|
* The filter may also pass non-IP and non-ARP packets, but we do
|
||||||
* a more complete check when receiving the message in userspace.
|
* a more complete check when receiving the message in userspace.
|
||||||
@ -1022,24 +1033,12 @@ static int udhcp_raw_socket(int ifindex)
|
|||||||
/* casting const away: */
|
/* casting const away: */
|
||||||
.filter = (struct sock_filter *) filter_instr,
|
.filter = (struct sock_filter *) filter_instr,
|
||||||
};
|
};
|
||||||
|
|
||||||
log1("Opening raw socket on ifindex %d", ifindex); //log2?
|
|
||||||
|
|
||||||
fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
|
|
||||||
log1("Got raw socket fd"); //log2?
|
|
||||||
|
|
||||||
sock.sll_family = AF_PACKET;
|
|
||||||
sock.sll_protocol = htons(ETH_P_IP);
|
|
||||||
sock.sll_ifindex = ifindex;
|
|
||||||
xbind(fd, (struct sockaddr *) &sock, sizeof(sock));
|
|
||||||
|
|
||||||
if (CLIENT_PORT == 68) {
|
|
||||||
/* Use only if standard port is in use */
|
|
||||||
/* Ignoring error (kernel may lack support for this) */
|
/* Ignoring error (kernel may lack support for this) */
|
||||||
if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog,
|
if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog,
|
||||||
sizeof(filter_prog)) >= 0)
|
sizeof(filter_prog)) >= 0)
|
||||||
log1("Attached filter to raw socket fd"); // log?
|
log1("Attached filter to raw socket fd"); // log?
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (setsockopt(fd, SOL_PACKET, PACKET_AUXDATA,
|
if (setsockopt(fd, SOL_PACKET, PACKET_AUXDATA,
|
||||||
&const_int_1, sizeof(int)) < 0
|
&const_int_1, sizeof(int)) < 0
|
||||||
|
Loading…
Reference in New Issue
Block a user