From: Roy Marples Date: Fri, 19 Jun 2015 14:17:18 +0000 (+0000) Subject: Move the BPF buffer from DHCP into IPv4 where it belongs. X-Git-Tag: v6.9.1~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ab234bd9cda4305eaaf56e2e823c41e59d1adff;p=thirdparty%2Fdhcpcd.git Move the BPF buffer from DHCP into IPv4 where it belongs. --- diff --git a/dhcp.c b/dhcp.c index 04c02998..91fc283e 100644 --- a/dhcp.c +++ b/dhcp.c @@ -3052,7 +3052,6 @@ dhcp_free(struct interface *ifp) free(state->old); free(state->new); free(state->offer); - free(state->buffer); free(state->clientid); free(state); ifp->if_data[IF_DATA_DHCP] = NULL; diff --git a/dhcp.h b/dhcp.h index cd5c12ac..8c962788 100644 --- a/dhcp.h +++ b/dhcp.h @@ -213,9 +213,6 @@ struct dhcp_state { int socket; int raw_fd; - size_t buffer_size, buffer_len, buffer_pos; - unsigned char *buffer; - struct in_addr addr; struct in_addr net; struct in_addr dst; diff --git a/if-bsd.c b/if-bsd.c index e82cd1db..58164ae4 100644 --- a/if-bsd.c +++ b/if-bsd.c @@ -293,7 +293,7 @@ const char *if_pfname = "Berkley Packet Filter"; int if_openrawsocket(struct interface *ifp, uint16_t protocol) { - struct dhcp_state *state; + struct ipv4_state *state; int fd = -1; struct ifreq ifr; int ibuf_len = 0; @@ -318,8 +318,7 @@ if_openrawsocket(struct interface *ifp, uint16_t protocol) if (fd == -1) return -1; - state = D_STATE(ifp); - + state = IPV4_STATE(ifp); memset(&pv, 0, sizeof(pv)); if (ioctl(fd, BIOCVERSION, &pv) == -1) goto eexit; @@ -403,9 +402,9 @@ if_readrawpacket(struct interface *ifp, uint16_t protocol, struct bpf_hdr packet; ssize_t bytes; const unsigned char *payload; - struct dhcp_state *state; + struct ipv4_state *state; - state = D_STATE(ifp); + state = IPV4_STATE(ifp); fd = ipv4_protocol_fd(ifp, protocol); *flags = 0; diff --git a/ipv4.c b/ipv4.c index d1d82509..c4a1ebbc 100644 --- a/ipv4.c +++ b/ipv4.c @@ -1113,6 +1113,9 @@ ipv4_free(struct interface *ifp) free(addr); } ipv4_freerts(&state->routes); +#ifdef BSD + free(state->buffer); +#endif free(state); } } diff --git a/ipv4.h b/ipv4.h index 8453fc28..4fd9b326 100644 --- a/ipv4.h +++ b/ipv4.h @@ -79,6 +79,12 @@ TAILQ_HEAD(ipv4_addrhead, ipv4_addr); struct ipv4_state { struct ipv4_addrhead addrs; struct rt_head routes; + +#ifdef BSD + /* Buffer for BPF */ + size_t buffer_size, buffer_len, buffer_pos; + unsigned char *buffer; +#endif }; #define IPV4_STATE(ifp) \