[LTP] [PATCH 2/2] pty04: use the correct protocol per line discipline to avoid extra packets
Vasileios Almpanis
vasileios.almpanis@virtuozzo.com
Fri Feb 6 13:51:13 CET 2026
Use specific protocol filter (ETH_P_IP for N_SLIP, ETH_P_CAN for N_SLCAN)
instead of ETH_P_ALL to avoid catching unrelated packets like IPv6
multicast (MLD) which cause false test failures.
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
testcases/kernel/pty/pty04.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/pty/pty04.c b/testcases/kernel/pty/pty04.c
index 204703253..770c053c4 100644
--- a/testcases/kernel/pty/pty04.c
+++ b/testcases/kernel/pty/pty04.c
@@ -258,6 +258,19 @@ static void open_netdev(const struct ldisc_info *ldisc)
{
struct ifreq ifreq = { 0 };
struct sockaddr_ll lla = { 0 };
+ int protocol;
+
+ switch (ldisc->n) {
+ case N_SLIP:
+ protocol = ETH_P_IP;
+ break;
+ case N_SLCAN:
+ protocol = ETH_P_CAN;
+ break;
+ default:
+ protocol = ETH_P_ALL;
+ break;
+ }
SAFE_IOCTL(pts, SIOCGIFNAME, ifreq.ifr_name);
tst_res(TINFO, "Netdev is %s", ifreq.ifr_name);
@@ -282,7 +295,7 @@ static void open_netdev(const struct ldisc_info *ldisc)
SAFE_IOCTL(sk, SIOCGIFINDEX, &ifreq);
lla.sll_family = PF_PACKET;
- lla.sll_protocol = htons(ETH_P_ALL);
+ lla.sll_protocol = htons(protocol);
lla.sll_ifindex = ifreq.ifr_ifindex;
SAFE_BIND(sk, (struct sockaddr *)&lla, sizeof(struct sockaddr_ll));
--
2.43.0
More information about the ltp
mailing list