bareudp: forbid mixing IP and MPLS in multiproto mode
authorGuillaume Nault <gnault@redhat.com>
Sat, 25 Jul 2020 13:06:47 +0000 (15:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Aug 2020 07:58:44 +0000 (09:58 +0200)
commit6bb24063d83ce49ded3775309102d69fff542e57
tree26a052b4f9255e08187022cfa5d0acd8d4c18525
parent9e387a01b5a2544bc4d54a814b47ab0b8f7f4ecd
bareudp: forbid mixing IP and MPLS in multiproto mode

[ Upstream commit 302d201b5cdf6f4781ee6cd9862f377f975d6c43 ]

In multiproto mode, bareudp_xmit() accepts sending multicast MPLS and
IPv6 packets regardless of the bareudp ethertype. In practice, this
let an IP tunnel send multicast MPLS packets, or an MPLS tunnel send
IPv6 packets.

We need to restrict the test further, so that the multiproto mode only
enables
  * IPv6 for IPv4 tunnels,
  * or multicast MPLS for unicast MPLS tunnels.

To improve clarity, the protocol validation is moved to its own
function, where each logical test has its own condition.

v2: s/ntohs/htons/

Fixes: 4b5f67232d95 ("net: Special handling for IP & MPLS.")
Signed-off-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/bareudp.c