Conversation
bpf/packetvisor.bpf.h
Outdated
| #define L3_FLAGS_IPV4 (1 << 0) | ||
| #define L3_FLAGS_IPV6 (1 << 1) | ||
| #define L3_FLAGS_EAPOL (1 << 2) | ||
| #define L3_FLAGS_OTHER (1 << 3) |
There was a problem hiding this comment.
Layer 2, 4는 RESERVED인데 여기는 OTHER인 이유는 있을까요?
bpf/packetvisor.bpf.h
Outdated
| /* L3 flags */ | ||
| #define L3_FLAGS_IPV4 (1 << 0) | ||
| #define L3_FLAGS_IPV6 (1 << 1) | ||
| #define L3_FLAGS_EAPOL (1 << 2) |
There was a problem hiding this comment.
| #define L3_FLAGS_EAPOL (1 << 2) |
src/lib.rs
Outdated
| pub const L2_FLAGS_ETH: u32 = 1 << 0; | ||
| pub const L2_FLAGS_VLAN: u32 = 1 << 1; | ||
| pub const L2_FLAGS_ARP: u32 = 1 << 2; | ||
| pub const L2_FLAGS_RESERVED: u32 = 1 << 3; | ||
|
|
||
| pub const L3_FLAGS_IPV4: u32 = 1 << 0; | ||
| pub const L3_FLAGS_IPV6: u32 = 1 << 1; | ||
| pub const L3_FLAGS_EAPOL: u32 = 1 << 2; | ||
| pub const L3_FLAGS_OTHER: u32 = 1 << 3; | ||
|
|
||
| pub const L4_FLAGS_TCP: u32 = 1 << 0; | ||
| pub const L4_FLAGS_UDP: u32 = 1 << 1; | ||
| pub const L4_FLAGS_ICMP: u32 = 1 << 2; | ||
| pub const L4_FLAGS_ICMPV6: u32 = 1 << 3; | ||
| pub const L4_FLAGS_OTHER: u32 = 1 << 4; | ||
| pub const L4_FLAGS_RESERVED: u32 = 1 << 5; | ||
|
|
||
| #[repr(C)] | ||
| #[derive(Clone, Copy, Debug, Default)] | ||
| pub struct AfXdpRxConfig { | ||
| pub l2_flags: u32, | ||
| pub l3_flags: u32, | ||
| pub l4_flags: u32, | ||
| } | ||
|
|
||
| impl AfXdpRxConfig { | ||
| pub fn kernel_only() -> Self { | ||
| Self { | ||
| l2_flags: 0, | ||
| l3_flags: 0, | ||
| l4_flags: 0, | ||
| } | ||
| } | ||
|
|
||
| pub fn arp_filter() -> Self { | ||
| Self { | ||
| l2_flags: L2_FLAGS_ETH | L2_FLAGS_VLAN | L2_FLAGS_ARP, | ||
| l3_flags: 0, | ||
| l4_flags: 0, | ||
| } | ||
| } | ||
|
|
||
| pub fn vlan_filter() -> Self { | ||
| Self { | ||
| l2_flags: L2_FLAGS_VLAN, | ||
| l3_flags: 0, | ||
| l4_flags: 0, | ||
| } | ||
| } | ||
|
|
||
| pub fn l3_other_filter() -> Self { | ||
| Self { | ||
| l2_flags: L2_FLAGS_ETH | L2_FLAGS_VLAN, | ||
| l3_flags: L3_FLAGS_OTHER, | ||
| l4_flags: 0, | ||
| } | ||
| } | ||
|
|
||
| pub fn eapol_filter() -> Self { | ||
| Self { | ||
| l2_flags: L2_FLAGS_ETH | L2_FLAGS_VLAN, | ||
| l3_flags: L3_FLAGS_EAPOL, | ||
| l4_flags: 0, | ||
| } | ||
| } | ||
|
|
||
| pub fn tcp_udp_userspace_filter() -> Self { | ||
| Self { | ||
| l2_flags: L2_FLAGS_ETH | L2_FLAGS_VLAN, | ||
| l3_flags: L3_FLAGS_IPV4 | L3_FLAGS_IPV6, | ||
| l4_flags: L4_FLAGS_TCP | L4_FLAGS_UDP, | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
lib.rs 내부가 아닌 다른 파일로 관리해주세요.
examples/echo/main.rs
Outdated
| completion_ring_size, | ||
| tx_ring_size, | ||
| rx_ring_size, | ||
| Some(pv::AfXdpRxConfig::user_all()), // config_map initial value |
There was a problem hiding this comment.
구현하신 AfXdpRxConfig 내부에는 user_all이라는 메소드가 없습니다.
src/lib.rs
Outdated
| } | ||
| } | ||
|
|
||
| pub fn tcp_udp_userspace_filter() -> Self { |
|
리니어 이슈랑 연결시켜주세요~! |
bpf/packetvisor.bpf.c
Outdated
| } | ||
| } | ||
|
|
||
| static __always_inline bool match_ipv6_l4(void *nh, void *data_end, __u32 l4_flags) |
There was a problem hiding this comment.
| static __always_inline bool match_ipv6_l4(void *nh, void *data_end, __u32 l4_flags) | |
| static __always_inline bool match_l4_over_ipv6(void *nh, void *data_end, __u32 l4_flags) |
bpf/packetvisor.bpf.c
Outdated
| } | ||
| } | ||
|
|
||
| static __always_inline bool match_ipv4_l4(void *nh, void *data_end, __u32 l4_flags) |
There was a problem hiding this comment.
| static __always_inline bool match_ipv4_l4(void *nh, void *data_end, __u32 l4_flags) | |
| static __always_inline bool match_l4_over_ipv4(void *nh, void *data_end, __u32 l4_flags) |
bpf/packetvisor.bpf.c
Outdated
| if (snap->dsap == 0xaa && snap->ssap == 0xaa && snap->ctrl == 0x03) { | ||
| if (snap->oui[0] == 0x00 && snap->oui[1] == 0x00 && snap->oui[2] == 0x00) { |
There was a problem hiding this comment.
dsap, ssap, ctrl과 비교되는 0xaa, 0xaa, 0x03이 무엇인지 매크로로 정의부탁드립니다.
src/lib.rs
Outdated
| pub const L2_FLAGS_ETH: u32 = 1 << 0; | ||
| pub const L2_FLAGS_VLAN: u32 = 1 << 1; | ||
| pub const L2_FLAGS_ARP: u32 = 1 << 2; | ||
| pub const L2_FLAGS_RESERVED: u32 = 1 << 3; | ||
|
|
||
| pub const L3_FLAGS_IPV4: u32 = 1 << 0; | ||
| pub const L3_FLAGS_IPV6: u32 = 1 << 1; | ||
| pub const L3_FLAGS_EAPOL: u32 = 1 << 2; | ||
| pub const L3_FLAGS_OTHER: u32 = 1 << 3; | ||
|
|
||
| pub const L4_FLAGS_TCP: u32 = 1 << 0; | ||
| pub const L4_FLAGS_UDP: u32 = 1 << 1; | ||
| pub const L4_FLAGS_ICMP: u32 = 1 << 2; | ||
| pub const L4_FLAGS_ICMPV6: u32 = 1 << 3; | ||
| pub const L4_FLAGS_OTHER: u32 = 1 << 4; | ||
| pub const L4_FLAGS_RESERVED: u32 = 1 << 5; | ||
|
|
||
| #[repr(C)] | ||
| #[derive(Clone, Copy, Debug, Default)] | ||
| pub struct AfXdpRxConfig { | ||
| pub l2_flags: u32, | ||
| pub l3_flags: u32, | ||
| pub l4_flags: u32, | ||
| } | ||
|
|
There was a problem hiding this comment.
얘들은 Impl AfXdpRxConfig 쪽으로 못빼나요?
Co-authored-by: pak-ji <pakji@tsnlab.com>
src/lib.rs
Outdated
| #[repr(C)] | ||
| #[derive(Clone, Copy, Debug, Default)] | ||
| pub struct AfXdpRxConfig { | ||
| pub l2_flags: u32, | ||
| pub l3_flags: u32, | ||
| pub l4_flags: u32, | ||
| } | ||
|
|
There was a problem hiding this comment.
xdp_config.rs에서 외부 모듈로 AfXdpRxConfig을 호출하지 않고, lib.rs에서 xdp_config.rs의 AfXdpRxConfig 구조체를 외부 모듈로 호출토록 해주세요.
There was a problem hiding this comment.
넵 lib.rs에서 use:crate::xdp_config::AfXdpRxConfig로 호출하도록 수정했습니다.
No description provided.