Lines 70-78
ps_bpf_recvbpf(void *arg)
Link Here
|
70 |
* This mechanism allows us to read each packet from the buffer. */ |
70 |
* This mechanism allows us to read each packet from the buffer. */ |
71 |
while (!(bpf->bpf_flags & BPF_EOF)) { |
71 |
while (!(bpf->bpf_flags & BPF_EOF)) { |
72 |
len = bpf_read(bpf, buf, sizeof(buf)); |
72 |
len = bpf_read(bpf, buf, sizeof(buf)); |
73 |
if (len == -1) |
73 |
if (len == -1) { |
74 |
logerr(__func__); |
74 |
int error = errno; |
75 |
if (len == -1 || len == 0) |
75 |
|
|
|
76 |
logerr("%s: %s", psp->psp_ifname, __func__); |
77 |
if (error != ENXIO) |
78 |
break; |
79 |
/* If the interface has departed, close the BPF |
80 |
* socket. This stops log spam if RTM_IFANNOUNCE is |
81 |
* delayed in announcing the departing interface. */ |
82 |
eloop_event_delete(psp->psp_ctx->eloop, bpf->bpf_fd); |
83 |
bpf_close(bpf); |
84 |
psp->psp_bpf = NULL; |
85 |
break; |
86 |
} |
87 |
if (len == 0) |
76 |
break; |
88 |
break; |
77 |
psm.ps_flags = bpf->bpf_flags; |
89 |
psm.ps_flags = bpf->bpf_flags; |
78 |
len = ps_sendpsmdata(psp->psp_ctx, psp->psp_ctx->ps_data_fd, |
90 |
len = ps_sendpsmdata(psp->psp_ctx, psp->psp_ctx->ps_data_fd, |
Lines 107-112
ps_bpf_recvmsgcb(void *arg, struct ps_msghdr *psm, struct msghdr *msg)
Link Here
|
107 |
return -1; |
119 |
return -1; |
108 |
} |
120 |
} |
109 |
|
121 |
|
|
|
122 |
/* We might have had an earlier ENXIO error. */ |
123 |
if (psp->psp_bpf == NULL) { |
124 |
errno = ENXIO; |
125 |
return -1; |
126 |
} |
127 |
|
110 |
return bpf_send(psp->psp_bpf, psp->psp_proto, |
128 |
return bpf_send(psp->psp_bpf, psp->psp_proto, |
111 |
iov->iov_base, iov->iov_len); |
129 |
iov->iov_base, iov->iov_len); |
112 |
} |
130 |
} |