Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa0010f8 authored by Amerigo Wang's avatar Amerigo Wang Committed by David S. Miller
Browse files

net: convert __IPTUNNEL_XMIT() to an inline function



__IPTUNNEL_XMIT() is an ugly macro, convert it to a static
inline function, so make it more readable.

IPTUNNEL_XMIT() is unused, just remove it.

Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: default avatarCong Wang <amwang@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bf0098f2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -769,7 +769,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)

	vxlan_set_owner(dev, skb);

	/* See __IPTUNNEL_XMIT */
	/* See iptunnel_xmit() */
	skb->ip_summed = CHECKSUM_NONE;
	ip_select_ident(iph, &rt->dst, NULL);

+10 −0
Original line number Diff line number Diff line
@@ -4,5 +4,15 @@
#include <linux/ip.h>
#include <linux/in6.h>
#include <uapi/linux/if_tunnel.h>
#include <linux/u64_stats_sync.h>

/* often modified stats are per cpu, other are shared (netdev->stats) */
struct pcpu_tstats {
	u64	rx_packets;
	u64	rx_bytes;
	u64	tx_packets;
	u64	tx_bytes;
	struct u64_stats_sync	syncp;
};

#endif /* _IF_TUNNEL_H_ */
+21 −19
Original line number Diff line number Diff line
@@ -48,25 +48,27 @@ struct ip_tunnel_prl_entry {
	struct rcu_head			rcu_head;
};

#define __IPTUNNEL_XMIT(stats1, stats2) do {				\
	int err;							\
	int pkt_len = skb->len - skb_transport_offset(skb);		\
									\
	skb->ip_summed = CHECKSUM_NONE;					\
	ip_select_ident(iph, &rt->dst, NULL);				\
									\
	err = ip_local_out(skb);					\
	if (likely(net_xmit_eval(err) == 0)) {				\
		u64_stats_update_begin(&(stats1)->syncp);		\
		(stats1)->tx_bytes += pkt_len;				\
		(stats1)->tx_packets++;					\
		u64_stats_update_end(&(stats1)->syncp);			\
	} else {							\
		(stats2)->tx_errors++;					\
		(stats2)->tx_aborted_errors++;				\
	}								\
} while (0)
static inline void iptunnel_xmit(struct sk_buff *skb, struct net_device *dev)
{
	int err;
	struct iphdr *iph = ip_hdr(skb);
	int pkt_len = skb->len - skb_transport_offset(skb);
	struct pcpu_tstats *tstats = this_cpu_ptr(dev->tstats);

#define IPTUNNEL_XMIT() __IPTUNNEL_XMIT(txq, stats)
	nf_reset(skb);
	skb->ip_summed = CHECKSUM_NONE;
	ip_select_ident(iph, skb_dst(skb), NULL);

	err = ip_local_out(skb);
	if (likely(net_xmit_eval(err) == 0)) {
		u64_stats_update_begin(&tstats->syncp);
		tstats->tx_bytes += pkt_len;
		tstats->tx_packets++;
		u64_stats_update_end(&tstats->syncp);
	} else {
		dev->stats.tx_errors++;
		dev->stats.tx_aborted_errors++;
	}
}

#endif
+1 −13
Original line number Diff line number Diff line
@@ -171,15 +171,6 @@ struct ipgre_net {
#define for_each_ip_tunnel_rcu(start) \
	for (t = rcu_dereference(start); t; t = rcu_dereference(t->next))

/* often modified stats are per cpu, other are shared (netdev->stats) */
struct pcpu_tstats {
	u64	rx_packets;
	u64	rx_bytes;
	u64	tx_packets;
	u64	tx_bytes;
	struct u64_stats_sync	syncp;
};

static struct rtnl_link_stats64 *ipgre_get_stats64(struct net_device *dev,
						   struct rtnl_link_stats64 *tot)
{
@@ -753,7 +744,6 @@ drop:
static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
{
	struct ip_tunnel *tunnel = netdev_priv(dev);
	struct pcpu_tstats *tstats;
	const struct iphdr  *old_iph = ip_hdr(skb);
	const struct iphdr  *tiph;
	struct flowi4 fl4;
@@ -977,9 +967,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
		}
	}

	nf_reset(skb);
	tstats = this_cpu_ptr(dev->tstats);
	__IPTUNNEL_XMIT(tstats, &dev->stats);
	iptunnel_xmit(skb, dev);
	return NETDEV_TX_OK;

#if IS_ENABLED(CONFIG_IPV6)
+0 −9
Original line number Diff line number Diff line
@@ -71,15 +71,6 @@ static int vti_tunnel_bind_dev(struct net_device *dev);
#define for_each_ip_tunnel_rcu(start) \
	for (t = rcu_dereference(start); t; t = rcu_dereference(t->next))

/* often modified stats are per cpu, other are shared (netdev->stats) */
struct pcpu_tstats {
	u64	rx_packets;
	u64	rx_bytes;
	u64	tx_packets;
	u64	tx_bytes;
	struct	u64_stats_sync	syncp;
};

#define VTI_XMIT(stats1, stats2) do {				\
	int err;						\
	int pkt_len = skb->len;					\
Loading