-
Notifications
You must be signed in to change notification settings - Fork 1
dhcpsd: -w waits for dynmically created interfaces #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
067d14a
7d2e669
a52125c
ef68a9b
fd33191
556721c
3e8db42
235c90f
acaf53d
a900878
cba68a4
bde9992
54d9a82
192daa3
d897954
e0780a2
362e90f
d9612d9
bfb0a40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -397,7 +397,7 @@ bpf_open(const struct interface *ifp, int (*filter)(const struct bpf *), | |
| #else | ||
| struct bpf_version pv = { .bv_major = 0, .bv_minor = 0 }; | ||
| struct ifreq ifr = { .ifr_flags = 0 }; | ||
| #if 0 | ||
| #if 1 | ||
| int ibuf_len = 0; | ||
| #endif | ||
|
Comment on lines
+400
to
402
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -e
printf 'bpf_open call sites and nearby flags:\n\n'
rg -nP -C3 '\bbpf_open\s*\(' src
printf '\nCurrent allocation guard in src/bpf.c:\n\n'
sed -n '505,518p' src/bpf.cRepository: NetworkConfiguration/dhcpsd Length of output: 1385 🏁 Script executed: #!/bin/bash
# 1. Check POSIX flag values in standard headers
echo "=== POSIX O_* flag definitions ==="
grep -rn "define O_RDONLY\|define O_WRONLY\|define O_RDWR\|define O_ACCMODE" /usr/include --include="*.h" 2>/dev/null | head -20
echo ""
echo "=== All bpf_open call sites ==="
rg -n '\bbpf_open\s*\(' src
echo ""
echo "=== Context: src/bpf.c lines 395-410 (around line 400) ==="
sed -n '395,410p' src/bpf.c
echo ""
echo "=== Context: src/bpf.c lines 505-520 (allocation guard) ==="
sed -n '505,520p' src/bpf.c
echo ""
echo "=== Check for bpf_read definition and usage ==="
grep -n "^bpf_read" src/bpf.c | head -5
rg -n 'bpf_read\s*\(' src --max-count=10Repository: NetworkConfiguration/dhcpsd Length of output: 1372 🏁 Script executed: #!/bin/bash
echo "=== All invocations of bpf_read() ==="
rg -n '\bbpf_read\s*\(' src
echo ""
echo "=== bpf_read function body (lines 534-560) ==="
sed -n '534,560p' src/bpf.c
echo ""
echo "=== Check lines 530-584 context mentioned in review ==="
sed -n '530,545p' src/bpf.c
echo ""
echo "=== Verify POSIX flag semantics via C headers ==="
cat > /tmp/check_flags.c << 'EOF'
`#include` <fcntl.h>
`#include` <stdio.h>
int main() {
printf("O_RDONLY=%d\nO_WRONLY=%d\nO_RDWR=%d\nO_ACCMODE=%d\n",
O_RDONLY, O_WRONLY, O_RDWR, O_ACCMODE);
printf("\nO_RDONLY & (O_RDONLY | O_RDWR) = %d\n", O_RDONLY & (O_RDONLY | O_RDWR));
printf("O_RDWR & (O_RDONLY | O_RDWR) = %d\n", O_RDWR & (O_RDONLY | O_RDWR));
printf("(O_RDONLY & O_ACCMODE) != O_WRONLY: %d\n", (O_RDONLY & O_ACCMODE) != O_WRONLY);
printf("(O_RDWR & O_ACCMODE) != O_WRONLY: %d\n", (O_RDWR & O_ACCMODE) != O_WRONLY);
printf("(O_WRONLY & O_ACCMODE) != O_WRONLY: %d\n", (O_WRONLY & O_ACCMODE) != O_WRONLY);
return 0;
}
EOF
gcc /tmp/check_flags.c -o /tmp/check_flags && /tmp/check_flagsRepository: NetworkConfiguration/dhcpsd Length of output: 1549 🏁 Script executed: #!/bin/bash
echo "=== Check if bpf_read is exported or used elsewhere ==="
rg -n 'bpf_read' src --type c --type h
echo ""
echo "=== Verify the flags semantics with known values ==="
python3 << 'EOF'
# POSIX standard values
O_RDONLY = 0
O_WRONLY = 1
O_RDWR = 2
O_ACCMODE = 3
print("POSIX flag values:")
print(f" O_RDONLY = {O_RDONLY}")
print(f" O_WRONLY = {O_WRONLY}")
print(f" O_RDWR = {O_RDWR}")
print(f" O_ACCMODE = {O_ACCMODE}")
print("\nCurrent guard: if (flags & (O_RDONLY | O_WRONLY))")
print(f" With O_RDONLY: {O_RDONLY} & ({O_RDONLY} | {O_RDWR}) = {O_RDONLY & (O_RDONLY | O_RDWR)} (False - FAILS TO ALLOCATE)")
print(f" With O_WRONLY: {O_WRONLY} & ({O_RDONLY} | {O_RDWR}) = {O_WRONLY & (O_RDONLY | O_RDWR)} (False - expected)")
print(f" With O_RDWR: {O_RDWR} & ({O_RDONLY} | {O_RDWR}) = {O_RDWR & (O_RDONLY | O_RDWR)} (True - correct)")
print("\nProposed fix: if ((flags & O_ACCMODE) != O_WRONLY)")
print(f" With O_RDONLY: ({O_RDONLY} & {O_ACCMODE}) != {O_WRONLY} = {(O_RDONLY & O_ACCMODE) != O_WRONLY} (True - correct)")
print(f" With O_WRONLY: ({O_WRONLY} & {O_ACCMODE}) != {O_WRONLY} = {(O_WRONLY & O_ACCMODE) != O_WRONLY} (False - correct)")
print(f" With O_RDWR: ({O_RDWR} & {O_ACCMODE}) != {O_WRONLY} = {(O_RDWR & O_ACCMODE) != O_WRONLY} (True - correct)")
EOF
echo ""
echo "=== Check bpf_read at line 543 for buffer access ==="
sed -n '540,545p' src/bpf.cRepository: NetworkConfiguration/dhcpsd Length of output: 1023 Allocate the BPF read buffer by access mode, not Re-enabling Proposed fix- if (flags & (O_RDONLY | O_RDWR)) {
+ if ((flags & O_ACCMODE) != O_WRONLY) {
/* Get the required BPF buffer length from the kernel. */
if (ioctl(bpf->bpf_fd, BIOCGBLEN, &ibuf_len) == -1)
goto eexit;🤖 Prompt for AI Agents |
||
| unsigned int imm; | ||
|
|
@@ -506,7 +506,6 @@ bpf_open(const struct interface *ifp, int (*filter)(const struct bpf *), | |
| #ifdef __linux__ | ||
| UNUSED(flags); | ||
| #else | ||
| #if 0 | ||
| if (flags & (O_RDONLY | O_RDWR)) { | ||
| /* Get the required BPF buffer length from the kernel. */ | ||
| if (ioctl(bpf->bpf_fd, BIOCGBLEN, &ibuf_len) == -1) | ||
|
|
@@ -517,7 +516,6 @@ bpf_open(const struct interface *ifp, int (*filter)(const struct bpf *), | |
| if (bpf->bpf_buffer == NULL) | ||
| goto eexit; | ||
| } | ||
| #endif | ||
| #endif | ||
|
|
||
| return bpf; | ||
|
|
@@ -568,7 +566,8 @@ bpf_read(struct bpf *bpf, void *data, size_t len) | |
| bytes = (ssize_t)len; | ||
| else | ||
| bytes = (ssize_t)packet.bh_caplen; | ||
| memcpy(data, payload, (size_t)bytes); | ||
| if (data) | ||
| memcpy(data, payload, (size_t)bytes); | ||
| next: | ||
| bpf->bpf_pos += BPF_WORDALIGN( | ||
| packet.bh_hdrlen + packet.bh_caplen); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.