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

Martin Doucha mdoucha@suse.cz
Wed Feb 11 17:44:25 CET 2026


Hi!
Good catch, but it'd be cleaner to add a "protocol" field to the 
ldisc_info structure instead of selecting protocol in a switch block.

On 2/6/26 13:51, Vasileios Almpanis via ltp wrote:
> 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));
>   


-- 
Martin Doucha   mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


More information about the ltp mailing list