aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/veth.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2009-11-26 01:07:08 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-26 18:52:58 -0500
commit445409602c09219767c06497c0dc2285eac244ed (patch)
tree5cfbd6d94f737107f3e6356fca2457ab3a66bb44 /drivers/net/veth.c
parent1bda8aa86b89d4c9b668000127ff87172f2daa10 (diff)
veth: move loopback logic to common location
The veth driver contains code to forward an skb from the start_xmit function of one network device into the receive path of another device. Moving that code into a common location lets us reuse the code for direct forwarding of data between macvlan ports, and possibly in other drivers. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/veth.c')
-rw-r--r--drivers/net/veth.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 2d657f2314cb..6c4b5a2d7877 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -155,8 +155,6 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
155 struct veth_net_stats *stats, *rcv_stats; 155 struct veth_net_stats *stats, *rcv_stats;
156 int length, cpu; 156 int length, cpu;
157 157
158 skb_orphan(skb);
159
160 priv = netdev_priv(dev); 158 priv = netdev_priv(dev);
161 rcv = priv->peer; 159 rcv = priv->peer;
162 rcv_priv = netdev_priv(rcv); 160 rcv_priv = netdev_priv(rcv);
@@ -168,20 +166,12 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
168 if (!(rcv->flags & IFF_UP)) 166 if (!(rcv->flags & IFF_UP))
169 goto tx_drop; 167 goto tx_drop;
170 168
171 if (skb->len > (rcv->mtu + MTU_PAD))
172 goto rx_drop;
173
174 skb->tstamp.tv64 = 0;
175 skb->pkt_type = PACKET_HOST;
176 skb->protocol = eth_type_trans(skb, rcv);
177 if (dev->features & NETIF_F_NO_CSUM) 169 if (dev->features & NETIF_F_NO_CSUM)
178 skb->ip_summed = rcv_priv->ip_summed; 170 skb->ip_summed = rcv_priv->ip_summed;
179 171
180 skb->mark = 0; 172 length = skb->len + ETH_HLEN;
181 secpath_reset(skb); 173 if (dev_forward_skb(rcv, skb) != NET_RX_SUCCESS)
182 nf_reset(skb); 174 goto rx_drop;
183
184 length = skb->len;
185 175
186 stats->tx_bytes += length; 176 stats->tx_bytes += length;
187 stats->tx_packets++; 177 stats->tx_packets++;
@@ -189,7 +179,6 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
189 rcv_stats->rx_bytes += length; 179 rcv_stats->rx_bytes += length;
190 rcv_stats->rx_packets++; 180 rcv_stats->rx_packets++;
191 181
192 netif_rx(skb);
193 return NETDEV_TX_OK; 182 return NETDEV_TX_OK;
194 183
195tx_drop: 184tx_drop: