Skip to content

Commit 0621e6f

Browse files
ozshlomoSaeed Mahameed
authored andcommitted
net: Add netif_is_gretap()/netif_is_ip6gretap()
Changed the is_gretap_dev and is_ip6gretap_dev logic from structure comparison to string comparison of the rtnl_link_ops kind field. This approach aligns with the current identification methods and function names of vxlan and geneve network devices. Convert mlxsw to use these helpers and use them in downstream mlx5 patch. Signed-off-by: Oz Shlomo <[email protected]> Reviewed-by: Eli Britstein <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 101f4de commit 0621e6f

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ mlxsw_sp_span_entry_gretap4_deconfigure(struct mlxsw_sp_span_entry *span_entry)
383383
}
384384

385385
static const struct mlxsw_sp_span_entry_ops mlxsw_sp_span_entry_ops_gretap4 = {
386-
.can_handle = is_gretap_dev,
386+
.can_handle = netif_is_gretap,
387387
.parms = mlxsw_sp_span_entry_gretap4_parms,
388388
.configure = mlxsw_sp_span_entry_gretap4_configure,
389389
.deconfigure = mlxsw_sp_span_entry_gretap4_deconfigure,
@@ -484,7 +484,7 @@ mlxsw_sp_span_entry_gretap6_deconfigure(struct mlxsw_sp_span_entry *span_entry)
484484

485485
static const
486486
struct mlxsw_sp_span_entry_ops mlxsw_sp_span_entry_ops_gretap6 = {
487-
.can_handle = is_ip6gretap_dev,
487+
.can_handle = netif_is_ip6gretap,
488488
.parms = mlxsw_sp_span_entry_gretap6_parms,
489489
.configure = mlxsw_sp_span_entry_gretap6_configure,
490490
.deconfigure = mlxsw_sp_span_entry_gretap6_deconfigure,

include/net/gre.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,17 @@ struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
3737
int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
3838
bool *csum_err, __be16 proto, int nhs);
3939

40-
bool is_gretap_dev(const struct net_device *dev);
41-
bool is_ip6gretap_dev(const struct net_device *dev);
40+
static inline bool netif_is_gretap(const struct net_device *dev)
41+
{
42+
return dev->rtnl_link_ops &&
43+
!strcmp(dev->rtnl_link_ops->kind, "gretap");
44+
}
45+
46+
static inline bool netif_is_ip6gretap(const struct net_device *dev)
47+
{
48+
return dev->rtnl_link_ops &&
49+
!strcmp(dev->rtnl_link_ops->kind, "ip6gretap");
50+
}
4251

4352
static inline int gre_calc_hlen(__be16 o_flags)
4453
{

net/ipv4/ip_gre.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,12 +1341,6 @@ static void ipgre_tap_setup(struct net_device *dev)
13411341
ip_tunnel_setup(dev, gre_tap_net_id);
13421342
}
13431343

1344-
bool is_gretap_dev(const struct net_device *dev)
1345-
{
1346-
return dev->netdev_ops == &gre_tap_netdev_ops;
1347-
}
1348-
EXPORT_SYMBOL_GPL(is_gretap_dev);
1349-
13501344
static int ipgre_newlink(struct net *src_net, struct net_device *dev,
13511345
struct nlattr *tb[], struct nlattr *data[],
13521346
struct netlink_ext_ack *extack)

net/ipv6/ip6_gre.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,12 +1885,6 @@ static void ip6gre_tap_setup(struct net_device *dev)
18851885
netif_keep_dst(dev);
18861886
}
18871887

1888-
bool is_ip6gretap_dev(const struct net_device *dev)
1889-
{
1890-
return dev->netdev_ops == &ip6gre_tap_netdev_ops;
1891-
}
1892-
EXPORT_SYMBOL_GPL(is_ip6gretap_dev);
1893-
18941888
static bool ip6gre_netlink_encap_parms(struct nlattr *data[],
18951889
struct ip_tunnel_encap *ipencap)
18961890
{

0 commit comments

Comments
 (0)