Make raw listen sockets nonblocking. They should have been so all along.
Minor constant correction: PF_PACKET -> AF_PACKET
This commit is contained in:
parent
19f7e6d11e
commit
7d206e45b6
@ -169,7 +169,7 @@ int raw_packet(struct dhcpMessage *payload, uint32_t source_ip,
|
|||||||
int fd, r = -1;
|
int fd, r = -1;
|
||||||
unsigned int padding;
|
unsigned int padding;
|
||||||
|
|
||||||
if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
|
if ((fd = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
|
||||||
log_error("raw_packet: socket failed: %s", strerror(errno));
|
log_error("raw_packet: socket failed: %s", strerror(errno));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -178,6 +178,8 @@ int raw_packet(struct dhcpMessage *payload, uint32_t source_ip,
|
|||||||
memset(&packet, 0, offsetof(struct ip_udp_dhcp_packet, data));
|
memset(&packet, 0, offsetof(struct ip_udp_dhcp_packet, data));
|
||||||
packet.data = *payload; /* struct copy */
|
packet.data = *payload; /* struct copy */
|
||||||
|
|
||||||
|
set_sock_nonblock(fd);
|
||||||
|
|
||||||
dest.sll_family = AF_PACKET;
|
dest.sll_family = AF_PACKET;
|
||||||
dest.sll_protocol = htons(ETH_P_IP);
|
dest.sll_protocol = htons(ETH_P_IP);
|
||||||
dest.sll_ifindex = ifindex;
|
dest.sll_ifindex = ifindex;
|
||||||
|
@ -126,7 +126,7 @@ int raw_socket(int ifindex)
|
|||||||
|
|
||||||
memset(&sock, 0, sizeof sock);
|
memset(&sock, 0, sizeof sock);
|
||||||
log_line("Opening raw socket on ifindex %d", ifindex);
|
log_line("Opening raw socket on ifindex %d", ifindex);
|
||||||
if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
|
if ((fd = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
|
||||||
log_error("socket call failed: %s", strerror(errno));
|
log_error("socket call failed: %s", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user