aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Hibbits <jhibbits@FreeBSD.org>2023-01-24 21:17:55 +0000
committerJustin Hibbits <jhibbits@FreeBSD.org>2023-01-31 20:02:15 +0000
commit113af4fd2bcb464307daf8ca053dc728db8da61d (patch)
tree5a39cfbff6b675f543c60c8b6c7bf43c9fd14cae
parent950cc1f44fbd5965db7b679c0aaf1bd9b432ec25 (diff)
downloadsrc-113af4fd2bcb464307daf8ca053dc728db8da61d.tar.gz
src-113af4fd2bcb464307daf8ca053dc728db8da61d.zip
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
-rw-r--r--sys/net/if.c6
-rw-r--r--sys/net/if_var.h1
-rw-r--r--sys/net/if_vlan_var.h10
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)