platform: assert in nm_platform_link_tun_add() for unsupported options

It doesn't make sense that NetworkManager adds non-persist tun
devices, likewise, only the type IFF_TUN or IFF_TAP is supported.

Assert that the values are as expected.
This commit is contained in:
Thomas Haller
2018-04-05 17:33:21 +02:00
parent 01ad4f33ed
commit 28b5118ad2

View File

@@ -5597,8 +5597,9 @@ link_tun_add (NMPlatform *platform,
struct ifreq ifr = { };
nm_auto_close int fd = -1;
if (!NM_IN_SET (props->type, IFF_TAP, IFF_TUN))
return FALSE;
if ( !NM_IN_SET (props->type, IFF_TAP, IFF_TUN)
|| !props->persist)
g_return_val_if_reached (FALSE);
fd = open ("/dev/net/tun", O_RDWR | O_CLOEXEC);
if (fd < 0)