File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,7 @@ bpf_open(const struct interface *ifp,
170
170
if (bpf == NULL )
171
171
return NULL ;
172
172
bpf -> bpf_ifp = ifp ;
173
+ bpf -> bpf_flags = BPF_EOF ;
173
174
174
175
/* /dev/bpf is a cloner on modern kernels */
175
176
bpf -> bpf_fd = open ("/dev/bpf" , BPF_OPEN_FLAGS );
@@ -218,10 +219,12 @@ bpf_open(const struct interface *ifp,
218
219
/* Get the required BPF buffer length from the kernel. */
219
220
if (ioctl (bpf -> bpf_fd , BIOCGBLEN , & ibuf_len ) == -1 )
220
221
goto eexit ;
222
+
221
223
bpf -> bpf_size = (size_t )ibuf_len ;
222
224
bpf -> bpf_buffer = malloc (bpf -> bpf_size );
223
225
if (bpf -> bpf_buffer == NULL )
224
226
goto eexit ;
227
+
225
228
return bpf ;
226
229
227
230
eexit :
Original file line number Diff line number Diff line change @@ -2236,12 +2236,18 @@ dhcp_arp_defend_failed(struct arp_state *astate)
2236
2236
{
2237
2237
struct interface * ifp = astate -> iface ;
2238
2238
struct dhcp_state * state = D_STATE (ifp );
2239
+ unsigned int delay ;
2239
2240
2240
2241
if (!(ifp -> options -> options & (DHCPCD_INFORM | DHCPCD_STATIC )))
2241
2242
dhcp_decline (ifp );
2242
2243
dhcp_drop (ifp , "EXPIRED" );
2243
2244
dhcp_unlink (ifp -> ctx , state -> leasefile );
2244
- dhcp_start1 (ifp );
2245
+
2246
+ // Delay restarting to give time for the BPF ARP process to exit
2247
+ // as we may spawn a new one with a different filter fairly quickly
2248
+ delay = MSEC_PER_SEC +
2249
+ (arc4random_uniform (MSEC_PER_SEC * 2 ) - MSEC_PER_SEC );
2250
+ eloop_timeout_add_msec (ifp -> ctx -> eloop , delay , dhcp_start1 , ifp );
2245
2251
}
2246
2252
#endif
2247
2253
Original file line number Diff line number Diff line change @@ -1850,6 +1850,7 @@ bpf_open(const struct interface *ifp,
1850
1850
if (bpf == NULL )
1851
1851
return NULL ;
1852
1852
bpf -> bpf_ifp = ifp ;
1853
+ bpf -> bpf_flags = BPF_EOF ;
1853
1854
1854
1855
/* Allocate a suitably large buffer for a single packet. */
1855
1856
bpf -> bpf_size = ETH_FRAME_LEN ;
You can’t perform that action at this time.
0 commit comments