Re: Support for "raw-ip" mode
Roy Marples
Tue Aug 20 14:26:20 2019
On 20/08/2019 14:50, Yegor Yefremov wrote:
APPLYING FILTER
dhcp_openbpf: wwan0: Invalid argument
OK, that's odd.
The filter is still valid.
Did the patch not apply correctly?
Here is a new one, with more debug:
Roy
diff --git a/src/bpf.c b/src/bpf.c
index c321bb70..921cba11 100644
--- a/src/bpf.c
+++ b/src/bpf.c
@@ -663,8 +663,13 @@ bpf_bootp(struct interface *ifp, int fd)
return 0;
bp = bpf;
+ logerrx("BOOTP FILTER 1 %p %p", bpf, bp);
/* Check frame header. */
switch(ifp->family) {
+#ifdef ARPHRD_NETROM
+ case ARPHRD_NETROM:
+ break;
+#endif
case ARPHRD_ETHER:
memcpy(bp, bpf_bootp_ether, sizeof(bpf_bootp_ether));
bp += BPF_BOOTP_ETHER_LEN;
@@ -674,6 +679,8 @@ bpf_bootp(struct interface *ifp, int fd)
return -1;
}
+ logerrx("BOOTP FILTER 2 %p %p", bpf, bp);
+
/* Copy in the main filter. */
memcpy(bp, bpf_bootp_filter, sizeof(bpf_bootp_filter));
bp += BPF_BOOTP_FILTER_LEN;
@@ -714,6 +721,8 @@ bpf_bootp(struct interface *ifp, int fd)
}
#endif
+ logerrx("BOOTP FILTER 3 %p %p", bpf, bp);
+
/* All passed, return the packet - frame length + ip length */
BPF_SET_STMT(bp, BPF_LD + BPF_MEM, BPF_M_FHLEN);
bp++;
@@ -724,5 +733,7 @@ bpf_bootp(struct interface *ifp, int fd)
BPF_SET_STMT(bp, BPF_RET + BPF_A, 0);
bp++;
+ logerrx("BOOTP FILTER 4 %p %p", bpf, bp);
+
return bpf_attach(fd, bpf, (unsigned int)(bp - bpf));
}
diff --git a/src/if-linux.c b/src/if-linux.c
index b7e84eb5..d033a58e 100644
--- a/src/if-linux.c
+++ b/src/if-linux.c
@@ -1357,6 +1357,7 @@ bpf_open(struct interface *ifp, int (*filter)(struct interface *, int))
int n;
#endif
+ logerrx("OPEN BPF SOCKET");
#define SF SOCK_CLOEXEC | SOCK_NONBLOCK
if ((s = xsocket(PF_PACKET, SOCK_RAW | SF, htons(ETH_P_ALL))) == -1)
return -1;
@@ -1376,10 +1377,12 @@ bpf_open(struct interface *ifp, int (*filter)(struct interface *, int))
state->buffer_len = state->buffer_pos = 0;
}
+ logerrx("APPLYING FILTER");
if (filter(ifp, s) != 0)
goto eexit;
#ifdef PACKET_AUXDATA
+ logerrx("TOGGLING PACKET_AUXDATA");
n = 1;
if (setsockopt(s, SOL_PACKET, PACKET_AUXDATA, &n, sizeof(n)) != 0) {
if (errno != ENOPROTOOPT)
@@ -1391,6 +1394,7 @@ bpf_open(struct interface *ifp, int (*filter)(struct interface *, int))
su.sll.sll_family = PF_PACKET;
su.sll.sll_protocol = htons(ETH_P_ALL);
su.sll.sll_ifindex = (int)ifp->index;
+ logerrx("BINDING SOCKET");
if (bind(s, &su.sa, sizeof(su.sll)) == -1)
goto eexit;
return s;
Archive administrator: postmaster@marples.name