From ad959c3040cb1bfcc6464ee74fda900eeb4da04b Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 22 May 2026 14:24:17 +0100 Subject: [PATCH 1/3] Add IPPROTO IPV6 and MPTCP --- rules/ip/ir_unsafe.json | 20 ++++++++++++++++++++ rules/ip/src.cpp | 8 ++++++++ rules/ip/tgt_unsafe.rs | 8 ++++++++ 3 files changed, 36 insertions(+) diff --git a/rules/ip/ir_unsafe.json b/rules/ip/ir_unsafe.json index 8aed2831..51111c6c 100644 --- a/rules/ip/ir_unsafe.json +++ b/rules/ip/ir_unsafe.json @@ -28,5 +28,25 @@ "return_type": { "type": "i32" } + }, + "f4": { + "body": [ + { + "text": "libc::IPPROTO_IPV6" + } + ], + "return_type": { + "type": "i32" + } + }, + "f5": { + "body": [ + { + "text": "libc::IPPROTO_MPTCP" + } + ], + "return_type": { + "type": "i32" + } } } diff --git a/rules/ip/src.cpp b/rules/ip/src.cpp index 200abfc0..c66ba9fe 100644 --- a/rules/ip/src.cpp +++ b/rules/ip/src.cpp @@ -11,3 +11,11 @@ int f2() { int f3() { return IPPROTO_IP; } + +int f4() { + return IPPROTO_IPV6; +} + +int f5() { + return IPPROTO_MPTCP; +} diff --git a/rules/ip/tgt_unsafe.rs b/rules/ip/tgt_unsafe.rs index 7325fc09..766ed978 100644 --- a/rules/ip/tgt_unsafe.rs +++ b/rules/ip/tgt_unsafe.rs @@ -9,3 +9,11 @@ unsafe fn f2() -> i32 { unsafe fn f3() -> i32 { libc::IPPROTO_IP } + +unsafe fn f4() -> i32 { + libc::IPPROTO_IPV6 +} + +unsafe fn f5() -> i32 { + libc::IPPROTO_MPTCP +} From 2f1463f6041f756ac56cfda46de70dab91fc8a29 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 22 May 2026 14:25:18 +0100 Subject: [PATCH 2/3] Update tests --- tests/unit/ipproto_macros.cpp | 4 +++- tests/unit/out/refcount/ipproto_macros.rs | 5 ++++- tests/unit/out/unsafe/ipproto_macros.rs | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/unit/ipproto_macros.cpp b/tests/unit/ipproto_macros.cpp index 39515059..8b049636 100644 --- a/tests/unit/ipproto_macros.cpp +++ b/tests/unit/ipproto_macros.cpp @@ -4,5 +4,7 @@ int main() { int tcp = IPPROTO_TCP; int udp = IPPROTO_UDP; int ip = IPPROTO_IP; - return tcp + udp + ip; + int ip6 = IPPROTO_IPV6; + int mptcp = IPPROTO_MPTCP; + return tcp + udp + ip + ip6 + mptcp; } diff --git a/tests/unit/out/refcount/ipproto_macros.rs b/tests/unit/out/refcount/ipproto_macros.rs index f9017278..f5da640d 100644 --- a/tests/unit/out/refcount/ipproto_macros.rs +++ b/tests/unit/out/refcount/ipproto_macros.rs @@ -13,5 +13,8 @@ fn main_0() -> i32 { let tcp: Value = Rc::new(RefCell::new(libc::IPPROTO_TCP)); let udp: Value = Rc::new(RefCell::new(libc::IPPROTO_UDP)); let ip: Value = Rc::new(RefCell::new(libc::IPPROTO_IP)); - return (((*tcp.borrow()) + (*udp.borrow())) + (*ip.borrow())); + let ip6: Value = Rc::new(RefCell::new(libc::IPPROTO_IPV6)); + let mptcp: Value = Rc::new(RefCell::new(libc::IPPROTO_MPTCP)); + return (((((*tcp.borrow()) + (*udp.borrow())) + (*ip.borrow())) + (*ip6.borrow())) + + (*mptcp.borrow())); } diff --git a/tests/unit/out/unsafe/ipproto_macros.rs b/tests/unit/out/unsafe/ipproto_macros.rs index 4ff8e7f7..3f9d4753 100644 --- a/tests/unit/out/unsafe/ipproto_macros.rs +++ b/tests/unit/out/unsafe/ipproto_macros.rs @@ -15,5 +15,7 @@ unsafe fn main_0() -> i32 { let mut tcp: i32 = libc::IPPROTO_TCP; let mut udp: i32 = libc::IPPROTO_UDP; let mut ip: i32 = libc::IPPROTO_IP; - return (((tcp) + (udp)) + (ip)); + let mut ip6: i32 = libc::IPPROTO_IPV6; + let mut mptcp: i32 = libc::IPPROTO_MPTCP; + return (((((tcp) + (udp)) + (ip)) + (ip6)) + (mptcp)); } From d8d80fd05941a85f46c2cadd7be47d193fb5d428 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 22 May 2026 14:40:29 +0100 Subject: [PATCH 3/3] Guard IPPROT_MPTCP on Linux only --- rules/ip/src.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rules/ip/src.cpp b/rules/ip/src.cpp index c66ba9fe..1fabb8b2 100644 --- a/rules/ip/src.cpp +++ b/rules/ip/src.cpp @@ -16,6 +16,8 @@ int f4() { return IPPROTO_IPV6; } +#if defined(__linux__) int f5() { return IPPROTO_MPTCP; } +#endif