git: 113af4fd2bcb - main - IfAPI: Add if_gettype() API and use it for vlan
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 31 Jan 2023 20:03:14 UTC
The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=113af4fd2bcb464307daf8ca053dc728db8da61d commit 113af4fd2bcb464307daf8ca053dc728db8da61d Author: Justin Hibbits <jhibbits@FreeBSD.org> AuthorDate: 2023-01-24 21:17:55 +0000 Commit: Justin Hibbits <jhibbits@FreeBSD.org> CommitDate: 2023-01-31 20:02:15 +0000 IfAPI: Add if_gettype() API and use it for vlan Sponsored by: Juniper Networks, Inc. Reviewed by: #network, glebius Differential Revision: https://reviews.freebsd.org/D38198 --- sys/net/if.c | 6 ++++++ sys/net/if_var.h | 1 + sys/net/if_vlan_var.h | 10 +++++----- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index ff505e1a1fe8..96093d0a2aa3 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -4809,6 +4809,12 @@ if_setdebugnet_methods(if_t ifp, struct debugnet_methods *m) ifp->if_debugnet_methods = m; } +int +if_gettype(if_t ifp) +{ + return (ifp->if_type); +} + #ifdef DDB static void if_show_ifnet(struct ifnet *ifp) diff --git a/sys/net/if_var.h b/sys/net/if_var.h index e794811e090e..4c54d26a921d 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -584,6 +584,7 @@ void if_setdescr(if_t ifp, char *descrbuf); char *if_allocdescr(size_t sz, int malloc_flag); void if_freedescr(char *descrbuf); int if_getalloctype(const if_t ifp); +int if_gettype(const if_t ifp); int if_setdev(if_t ifp, void *dev); int if_setdrvflagbits(if_t ifp, int if_setflags, int clear_flags); int if_getdrvflags(const if_t ifp); diff --git a/sys/net/if_vlan_var.h b/sys/net/if_vlan_var.h index 91bed40c43a6..b383d0898c9a 100644 --- a/sys/net/if_vlan_var.h +++ b/sys/net/if_vlan_var.h @@ -143,15 +143,15 @@ struct ether_8021q_tag { } while (0) #define VLAN_TRUNKDEV(_ifp) \ - ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_trunkdev_p)((_ifp)) : NULL) + (if_gettype(_ifp) == IFT_L2VLAN ? (*vlan_trunkdev_p)((_ifp)) : NULL) #define VLAN_TAG(_ifp, _vid) \ - ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_tag_p)((_ifp), (_vid)) : EINVAL) + (if_gettype(_ifp) == IFT_L2VLAN ? (*vlan_tag_p)((_ifp), (_vid)) : EINVAL) #define VLAN_PCP(_ifp, _pcp) \ - ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_pcp_p)((_ifp), (_pcp)) : EINVAL) + (if_gettype(_ifp) == IFT_L2VLAN ? (*vlan_pcp_p)((_ifp), (_pcp)) : EINVAL) #define VLAN_COOKIE(_ifp) \ - ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_cookie_p)((_ifp)) : NULL) + (if_gettype(_ifp) == IFT_L2VLAN ? (*vlan_cookie_p)((_ifp)) : NULL) #define VLAN_SETCOOKIE(_ifp, _cookie) \ - ((_ifp)->if_type == IFT_L2VLAN ? \ + (if_gettype(_ifp) == IFT_L2VLAN ? \ (*vlan_setcookie_p)((_ifp), (_cookie)) : EINVAL) #define VLAN_DEVAT(_ifp, _vid) \ ((_ifp)->if_vlantrunk != NULL ? (*vlan_devat_p)((_ifp), (_vid)) : NULL)