Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
36116b3f
Commit
36116b3f
authored
Jul 09, 2014
by
Marcin Siodelski
Browse files
[2893] Configure the address family of the BPF program for lo interface.
parent
7ff23f2b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcp/pkt_filter_bpf.cc
View file @
36116b3f
...
...
@@ -110,9 +110,10 @@ struct bpf_insn ethernet_ip_udp_filter [] = {
struct
bpf_insn
loopback_ip_udp_filter
[]
=
{
// Make sure this is an IP packet. The pseudo header comprises a 4-byte
// long value identifying the address family, which should be set to
// AF_INET.
// AF_INET. The default value used here (0xFFFFFFFF) must be overriden
// with htonl(AF_INET) from within the openSocket function.
BPF_STMT
(
BPF_LD
+
BPF_W
+
BPF_ABS
,
0
),
BPF_JUMP
(
BPF_JMP
+
BPF_JEQ
+
BPF_K
,
htonl
(
AF_INET
)
,
0
,
8
),
BPF_JUMP
(
BPF_JMP
+
BPF_JEQ
+
BPF_K
,
0xFFFFFFFF
,
0
,
8
),
// Make sure it's a UDP packet. The IP protocol is at offset
// 9 in the IP header so, adding the pseudo header size 4 bytes
...
...
@@ -257,6 +258,11 @@ PktFilterBPF::openSocket(Iface& iface,
if
(
iface
.
flag_loopback_
)
{
prog
.
bf_insns
=
loopback_ip_udp_filter
;
prog
.
bf_len
=
sizeof
(
loopback_ip_udp_filter
)
/
sizeof
(
struct
bpf_insn
);
// The address family is AF_INET. It can't be hardcoded in the BPF program
// because we need to make the host to network order conversion using htonl
// and conversion can't be done within the BPF program structure as it
// doesn't work on some systems.
prog
.
bf_insns
[
1
].
k
=
htonl
(
AF_INET
);
}
else
{
prog
.
bf_insns
=
ethernet_ip_udp_filter
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment