Skip to content

Add custom filtering module#99

Merged
GyuBa merged 32 commits intomasterfrom
add-xdp-module
Feb 24, 2026
Merged

Add custom filtering module#99
GyuBa merged 32 commits intomasterfrom
add-xdp-module

Conversation

@GyuBa
Copy link
Copy Markdown
Contributor

@GyuBa GyuBa commented Jan 29, 2026

No description provided.

Copy link
Copy Markdown
Contributor

@pak-ji pak-ji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint 에러 나는 부분도 처리부탁드립니다.

#define L3_FLAGS_IPV4 (1 << 0)
#define L3_FLAGS_IPV6 (1 << 1)
#define L3_FLAGS_EAPOL (1 << 2)
#define L3_FLAGS_OTHER (1 << 3)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layer 2, 4는 RESERVED인데 여기는 OTHER인 이유는 있을까요?

/* L3 flags */
#define L3_FLAGS_IPV4 (1 << 0)
#define L3_FLAGS_IPV6 (1 << 1)
#define L3_FLAGS_EAPOL (1 << 2)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define L3_FLAGS_EAPOL (1 << 2)

src/lib.rs Outdated
Comment on lines +66 to +139
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,
}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib.rs 내부가 아닌 다른 파일로 관리해주세요.

completion_ring_size,
tx_ring_size,
rx_ring_size,
Some(pv::AfXdpRxConfig::user_all()), // config_map initial value
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

구현하신 AfXdpRxConfig 내부에는 user_all이라는 메소드가 없습니다.

src/lib.rs Outdated
}
}

pub fn tcp_udp_userspace_filter() -> Self {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위에 메소드들이랑 이름을 비슷하게 지어주세요.

@pak-ji
Copy link
Copy Markdown
Contributor

pak-ji commented Feb 2, 2026

@GyuBa,

리니어 이슈랑 연결시켜주세요~!

}
}

static __always_inline bool match_ipv6_l4(void *nh, void *data_end, __u32 l4_flags)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

}
}

static __always_inline bool match_ipv4_l4(void *nh, void *data_end, __u32 l4_flags)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Comment on lines +233 to +234
if (snap->dsap == 0xaa && snap->ssap == 0xaa && snap->ctrl == 0x03) {
if (snap->oui[0] == 0x00 && snap->oui[1] == 0x00 && snap->oui[2] == 0x00) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dsap, ssap, ctrl과 비교되는 0xaa, 0xaa, 0x03이 무엇인지 매크로로 정의부탁드립니다.

src/lib.rs Outdated
Comment on lines +68 to +92
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,
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

얘들은 Impl AfXdpRxConfig 쪽으로 못빼나요?

Co-authored-by: pak-ji <pakji@tsnlab.com>
src/lib.rs Outdated
Comment on lines +70 to +77
#[repr(C)]
#[derive(Clone, Copy, Debug, Default)]
pub struct AfXdpRxConfig {
pub l2_flags: u32,
pub l3_flags: u32,
pub l4_flags: u32,
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xdp_config.rs로 빼주세요.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정하였습니다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xdp_config.rs에서 외부 모듈로 AfXdpRxConfig을 호출하지 않고, lib.rs에서 xdp_config.rs의 AfXdpRxConfig 구조체를 외부 모듈로 호출토록 해주세요.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 lib.rs에서 use:crate::xdp_config::AfXdpRxConfig로 호출하도록 수정했습니다.

@GyuBa GyuBa merged commit a19b7df into master Feb 24, 2026
0 of 2 checks passed
@pak-ji pak-ji deleted the add-xdp-module branch February 24, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants