netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: davem@redhat.com, kuznet@ms2.inr.ac.ru, hadi@cyberus.ca
Cc: netdev@oss.sgi.com
Subject: [RFC/PATCH] Add support for setting net_device flags via RTM_SETLINK
Date: Mon, 23 Aug 2004 23:16:11 +0200	[thread overview]
Message-ID: <20040823211611.GC19921@postel.suug.ch> (raw)

Hello

The patch below extends RTM_SETLINK to change net_device flags if
a new value is provided via ifinfomsg and modifies the way flags
are shown to userspace to maintain balance and only show flags
which can be modified (as in ioctl handlers):

The change in behaviour:

old:
    r->ifi_flags = dev->flags;

    if (!netif_running(dev) || !netif_carrier_ok(dev))
        r->ifi_flags &= ~IFF_RUNNING;
    else
        r->ifi_flags |= IFF_RUNNING;

new:
    flags = (dev->flags & ~(IFF_PROMISC | IFF_ALLMULTI | IFF_RUNNING)) | 
            (dev->gflags & (IFF_PROMISC | IFF_ALLMULTI));

    if (netif_running(dev) && netif_carrier_ok(dev))
        flags |= IFF_RUNNING;

I will implement the 2 hidden flags IFF_PROMISC and IFF_ALLMULTI as separate
message attributes (IFLA_PROMISC and IFLA_ALLMULTI) as soon as I get some
comments on this idea.


--- 1.20/net/core/rtnetlink.c	Sun Aug 22 18:11:03 2004
+++ 1.21/net/core/rtnetlink.c	Mon Aug 23 22:32:39 2004
@@ -166,14 +166,9 @@
 	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);
 	RTA_PUT(skb, IFLA_TXQLEN, sizeof(unsigned long), &dev->tx_queue_len);
 	if (dev->addr_len) {
@@ -246,6 +241,9 @@
 		return -ENODEV;
 
 	err = -EINVAL;
+
+	if (ifm->ifi_flags)
+		dev_change_flags(dev, ifm->ifi_flags);
 
 	if (ida[IFLA_ADDRESS - 1]) {
 		if (!dev->set_mac_address) {

             reply	other threads:[~2004-08-23 21:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-23 21:16 Thomas Graf [this message]
2004-08-23 22:04 ` [RFC/PATCH] Add support for setting net_device flags via RTM_SETLINK Thomas Graf

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=20040823211611.GC19921@postel.suug.ch \
    --to=tgraf@suug.ch \
    --cc=davem@redhat.com \
    --cc=hadi@cyberus.ca \
    --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).