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

Martin Doucha mdoucha@suse.cz
Mon Mar 2 11:45:54 CET 2026


Hi,
the patch looks good and I've tested it on a vulnerable kernel.

Reviewed-by: Martin Doucha <mdoucha@suse.cz>

On 2/28/26 23:22, Vasileios Almpanis 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>
> ---
> 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));
>   


-- 
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