netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: "David S. Miller" <davem@redhat.com>
Cc: herbert@gondor.apana.org.au, kuznet@ms2.inr.ac.ru,
	hadi@cyberus.ca, netdev@oss.sgi.com
Subject: Re: [PATCH] allow setting mtu and txqlen via RTM_SETLINK and provide txqlen via RTM_GETLINK
Date: Tue, 24 Aug 2004 20:08:25 +0200	[thread overview]
Message-ID: <20040824180825.GJ21296@postel.suug.ch> (raw)
In-Reply-To: <20040824103252.1b593e68.davem@redhat.com>

* David S. Miller <20040824103252.1b593e68.davem@redhat.com> 2004-08-24 10:32
> On Tue, 24 Aug 2004 18:25:01 +0200
> Thomas Graf <tgraf@suug.ch> wrote:
> 
> > * Herbert Xu <E1BzYMJ-000208-00@gondolin.me.apana.org.au> 2004-08-24 20:16
> > > Please think about the meaning of the value.  Is anyone going to have a queue
> > > bigger than 2^32?
> > > 
> > > And if the answer is yes, then please use u64.
> > 
> > Here's a new patch with all discussed changes integrated. I don't have enough
> > cycles to split it all up again.
> 
> This patch only contained net/core/rtnetlink.c changes, where is
> the rest?

Sorry, the complete patch again:

--- 1.19/net/core/rtnetlink.c	Thu Apr 29 01:04:48 2004
+++ 1.27/net/core/rtnetlink.c	Tue Aug 24 18:16:40 2004
@@ -166,31 +166,53 @@
 	r->ifi_family = AF_UNSPEC;
 	r->ifi_type = dev->type;
 	r->ifi_index = dev->ifindex;
-	r->ifi_flags = dev->flags;
+	r->ifi_flags = dev_get_flags(dev);
 	r->ifi_change = change;
 
-	if (!netif_running(dev) || !netif_carrier_ok(dev))
-		r->ifi_flags &= ~IFF_RUNNING;
-	else
-		r->ifi_flags |= IFF_RUNNING;
-
 	RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name);
+
+	if (1) {
+		u32 txqlen = dev->tx_queue_len;
+		RTA_PUT(skb, IFLA_TXQLEN, sizeof(txqlen), &txqlen);
+	}
+
+	if (1) {
+		struct ifmap map = {
+			.mem_start   = dev->mem_start,
+			.mem_end     = dev->mem_end,
+			.base_addr   = dev->base_addr,
+			.irq         = dev->irq,
+			.dma         = dev->dma,
+			.port        = dev->if_port,
+		};
+		RTA_PUT(skb, IFLA_MAP, sizeof(map), &map);
+	}
+
 	if (dev->addr_len) {
 		RTA_PUT(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr);
 		RTA_PUT(skb, IFLA_BROADCAST, dev->addr_len, dev->broadcast);
 	}
+
 	if (1) {
-		unsigned mtu = dev->mtu;
+		u32 mtu = dev->mtu;
 		RTA_PUT(skb, IFLA_MTU, sizeof(mtu), &mtu);
 	}
-	if (dev->ifindex != dev->iflink)
-		RTA_PUT(skb, IFLA_LINK, sizeof(int), &dev->iflink);
+
+	if (dev->ifindex != dev->iflink) {
+		u32 iflink = dev->iflink;
+		RTA_PUT(skb, IFLA_LINK, sizeof(iflink), &iflink);
+	}
+
 	if (dev->qdisc_sleeping)
 		RTA_PUT(skb, IFLA_QDISC,
 			strlen(dev->qdisc_sleeping->ops->id) + 1,
 			dev->qdisc_sleeping->ops->id);
-	if (dev->master)
-		RTA_PUT(skb, IFLA_MASTER, sizeof(int), &dev->master->ifindex);
+	
+	if (dev->master) {
+		u32 master = dev->master->ifindex;
+		RTA_PUT(skb, IFLA_MASTER, sizeof(master), &master);
+	}
+
 	if (dev->get_stats) {
 		unsigned long *stats = (unsigned long*)dev->get_stats(dev);
 		if (stats) {
@@ -246,6 +268,30 @@
 
 	err = -EINVAL;
 
+	if (ifm->ifi_flags)
+		dev_change_flags(dev, ifm->ifi_flags);
+
+	if (ida[IFLA_MAP - 1]) {
+		if (!dev->set_config) {
+			err = -EOPNOTSUPP;
+			goto out;
+		}
+
+		if (!netif_device_present(dev)) {
+			err = -ENODEV;
+			goto out;
+		}
+		
+		if (ida[IFLA_MAP - 1]->rta_len != RTA_LENGTH(sizeof(struct ifmap)))
+			goto out;
+		
+		err = dev->set_config(dev, (struct ifmap *)
+				RTA_DATA(ida[IFLA_MAP - 1]));
+
+		if (err)
+			goto out;
+	}
+
 	if (ida[IFLA_ADDRESS - 1]) {
 		if (!dev->set_mac_address) {
 			err = -EOPNOTSUPP;
@@ -268,6 +314,23 @@
 			goto out;
 		memcpy(dev->broadcast, RTA_DATA(ida[IFLA_BROADCAST - 1]),
 		       dev->addr_len);
+	}
+
+	if (ida[IFLA_MTU - 1]) {
+		if (ida[IFLA_MTU - 1]->rta_len != RTA_LENGTH(sizeof(u32)))
+			goto out;
+		err = dev_set_mtu(dev, *((u32 *) RTA_DATA(ida[IFLA_MTU - 1])));
+
+		if (err)
+			goto out;
+
+	}
+
+	if (ida[IFLA_TXQLEN - 1]) {
+		if (ida[IFLA_TXQLEN - 1]->rta_len != RTA_LENGTH(sizeof(u32)))
+			goto out;
+
+		dev->tx_queue_len = *((u32 *) RTA_DATA(ida[IFLA_TXQLEN - 1]));
 	}
 
 	err = 0;


--- 1.33/include/linux/rtnetlink.h	Mon Apr  5 23:41:40 2004
+++ 1.35/include/linux/rtnetlink.h	Tue Aug 24 20:06:53 2004
@@ -540,6 +540,8 @@
 	IFLA_QDISC,
 	IFLA_STATS,
 	IFLA_COST,
+	IFLA_TXQLEN,
+	IFLA_MAP,
 #define IFLA_COST IFLA_COST
 	IFLA_PRIORITY,
 #define IFLA_PRIORITY IFLA_PRIORITY

  reply	other threads:[~2004-08-24 18:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-23 20:51 [PATCH] allow setting mtu and txqlen via RTM_SETLINK and provide txqlen via RTM_GETLINK Thomas Graf
2004-08-24  2:26 ` Herbert Xu
2004-08-24  9:49   ` Thomas Graf
2004-08-24 10:16     ` Herbert Xu
2004-08-24 12:04       ` Thomas Graf
2004-08-24 17:32         ` David S. Miller
2004-08-24 18:15           ` Thomas Graf
2004-08-24 20:47           ` [RFC/PATCH] Convert architecture dependent rtnetlink attribute to fixed sized ones Thomas Graf
2004-08-24 22:44             ` David S. Miller
2004-08-24 16:25       ` [PATCH] allow setting mtu and txqlen via RTM_SETLINK and provide txqlen via RTM_GETLINK Thomas Graf
2004-08-24 17:32         ` David S. Miller
2004-08-24 18:08           ` Thomas Graf [this message]
2004-08-25  0:34             ` David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040824180825.GJ21296@postel.suug.ch \
    --to=tgraf@suug.ch \
    --cc=davem@redhat.com \
    --cc=hadi@cyberus.ca \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).