Date: Mon, 6 May 2019 19:57:52 +0000 (UTC) From: Dmitry Chagin <dchagin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347203 - head/sys/compat/linux Message-ID: <201905061957.x46JvqP6025716@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dchagin Date: Mon May 6 19:57:51 2019 New Revision: 347203 URL: https://svnweb.freebsd.org/changeset/base/347203 Log: Rewrite linux_ifflags() in more readable Linuxulator style. Reviewed by: emaste MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20146 Modified: head/sys/compat/linux/linux.c head/sys/compat/linux/linux.h Modified: head/sys/compat/linux/linux.c ============================================================================== --- head/sys/compat/linux/linux.c Mon May 6 19:56:13 2019 (r347202) +++ head/sys/compat/linux/linux.c Mon May 6 19:57:51 2019 (r347203) @@ -269,16 +269,30 @@ ifname_linux_to_bsd(struct thread *td, const char *lxn void linux_ifflags(struct ifnet *ifp, short *flags) { + unsigned short fl; - *flags = (ifp->if_flags | ifp->if_drv_flags) & 0xffff; - /* these flags have no Linux equivalent */ - *flags &= ~(IFF_DRV_OACTIVE|IFF_SIMPLEX| - IFF_LINK0|IFF_LINK1|IFF_LINK2); - /* Linux' multicast flag is in a different bit */ - if (*flags & IFF_MULTICAST) { - *flags &= ~IFF_MULTICAST; - *flags |= 0x1000; - } + fl = (ifp->if_flags | ifp->if_drv_flags) & 0xffff; + *flags = 0; + if (fl & IFF_UP) + *flags |= LINUX_IFF_UP; + if (fl & IFF_BROADCAST) + *flags |= LINUX_IFF_BROADCAST; + if (fl & IFF_DEBUG) + *flags |= LINUX_IFF_DEBUG; + if (fl & IFF_LOOPBACK) + *flags |= LINUX_IFF_LOOPBACK; + if (fl & IFF_POINTOPOINT) + *flags |= LINUX_IFF_POINTOPOINT; + if (fl & IFF_DRV_RUNNING) + *flags |= LINUX_IFF_RUNNING; + if (fl & IFF_NOARP) + *flags |= LINUX_IFF_NOARP; + if (fl & IFF_PROMISC) + *flags |= LINUX_IFF_PROMISC; + if (fl & IFF_ALLMULTI) + *flags |= LINUX_IFF_ALLMULTI; + if (fl & IFF_MULTICAST) + *flags |= LINUX_IFF_MULTICAST; } int Modified: head/sys/compat/linux/linux.h ============================================================================== --- head/sys/compat/linux/linux.h Mon May 6 19:56:13 2019 (r347202) +++ head/sys/compat/linux/linux.h Mon May 6 19:57:51 2019 (r347203) @@ -46,6 +46,26 @@ struct l_sockaddr { #define LINUX_ARPHRD_ETHER 1 #define LINUX_ARPHRD_LOOPBACK 772 +/* + * net device flags + */ +#define LINUX_IFF_UP 0x0001 +#define LINUX_IFF_BROADCAST 0x0002 +#define LINUX_IFF_DEBUG 0x0004 +#define LINUX_IFF_LOOPBACK 0x0008 +#define LINUX_IFF_POINTOPOINT 0x0010 +#define LINUX_IFF_NOTRAILERS 0x0020 +#define LINUX_IFF_RUNNING 0x0040 +#define LINUX_IFF_NOARP 0x0080 +#define LINUX_IFF_PROMISC 0x0100 +#define LINUX_IFF_ALLMULTI 0x0200 +#define LINUX_IFF_MASTER 0x0400 +#define LINUX_IFF_SLAVE 0x0800 +#define LINUX_IFF_MULTICAST 0x1000 +#define LINUX_IFF_PORTSEL 0x2000 +#define LINUX_IFF_AUTOMEDIA 0x4000 +#define LINUX_IFF_DYNAMIC 0x8000 + /* sigaltstack */ #define LINUX_SS_ONSTACK 1 #define LINUX_SS_DISABLE 2
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905061957.x46JvqP6025716>