[LTP] [PATCH v3 1/1] pty04: use the correct protocol per line discipline to avoid extra packets

Vasileios Almpanis vasileios.almpanis@virtuozzo.com
Sat Feb 28 23:22:08 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>
---
v3:
- Removes switch statement
- Adds protocol to the ldisc_info structure

 testcases/kernel/pty/pty04.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/pty/pty04.c b/testcases/kernel/pty/pty04.c
index 204703253..720431685 100644
--- a/testcases/kernel/pty/pty04.c
+++ b/testcases/kernel/pty/pty04.c
@@ -84,11 +84,12 @@ struct ldisc_info {
 	int n;
 	char *name;
 	int mtu;
+	int protocol;
 };
 
 static struct ldisc_info ldiscs[] = {
-	{N_SLIP, "N_SLIP", 8192},
-	{N_SLCAN, "N_SLCAN", CAN_MTU},
+	{N_SLIP, "N_SLIP", 8192, ETH_P_IP},
+	{N_SLCAN, "N_SLCAN", CAN_MTU, ETH_P_CAN},
 };
 
 static int ptmx = -1, pts = -1, sk = -1, mtu, no_check;
@@ -282,7 +283,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(ldisc->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