netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] veth: keep peers MTU values synchronized
@ 2014-04-03 21:33 Ilya V. Matveychikov
  2014-04-04 14:25 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Ilya V. Matveychikov @ 2014-04-03 21:33 UTC (permalink / raw)
  To: netdev; +Cc: i.matveychikov

Keep peers MTU values synchronized. That prevent dropping packets while
forwarding as diffirent MTU values prevent skb moving from one peer's 
device to another (is_skb_forwardable returns false).

Signed-off-by: Ilya V. Matveychikov <i.matveychikov@securitycode.ru>
---
  drivers/net/veth.c | 16 +++++++++++++++-
  1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index c0e7c64..a975226 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -227,10 +227,24 @@ static int is_valid_veth_mtu(int new_mtu)

  static int veth_change_mtu(struct net_device *dev, int new_mtu)
  {
+	int err, old_mtu;
+	struct veth_priv *priv = netdev_priv(dev);
+	struct net_device *peer = rtnl_dereference(priv->peer);
+
+	if (!peer)
+		return -ENOTCONN;
+
  	if (!is_valid_veth_mtu(new_mtu))
  		return -EINVAL;
+
+	old_mtu = dev->mtu;
  	dev->mtu = new_mtu;
-	return 0;
+
+	err = dev_set_mtu(peer, new_mtu);
+	if (err)
+		dev->mtu = old_mtu;
+
+	return err;
  }

  static int veth_dev_init(struct net_device *dev)
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-04 15:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-03 21:33 [RFC PATCH] veth: keep peers MTU values synchronized Ilya V. Matveychikov
2014-04-04 14:25 ` David Miller
2014-04-04 14:42   ` Ilya V. Matveychikov
2014-04-04 14:49     ` David Miller
2014-04-04 15:04       ` Ilya V. Matveychikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).