From: Thomas Graf <tgraf@suug.ch>
To: jamal <hadi@cyberus.ca>
Cc: jt@hpl.hp.com, "David S. Miller" <davem@davemloft.net>,
netdev@oss.sgi.com
Subject: Re: [PATCH 2.6 NET] Device name changing via rtnetlink
Date: Sun, 12 Sep 2004 00:06:14 +0200 [thread overview]
Message-ID: <20040911220614.GF21181@postel.suug.ch> (raw)
In-Reply-To: <1094932793.2344.82.camel@jzny.localdomain>
* jamal <1094932793.2344.82.camel@jzny.localdomain> 2004-09-11 15:59
> So my suggestion is making your code the exception.
> i.e something along the lines of:
>
> addrchg = 1;
>
> if (mtu/weight/name related)
> addrchng = 0;
> if (!err & addrchang)
> call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
OK, however I'd prefer to invert the concept. See patch
below. This would send out the following updates:
ififlags - NETDEV_(UP|DOWN) if IFF_UP has changed
IFLA_MAP - none
IFLA_ADDRESS|IFLA_BROADCAST - NETDEV_CHANGEADDR
IFLA_MTU - NETDEV_CHANGEMTU
IFLA_WEIGHT - none
IFLA_IFNAME - NETDEVCHANGENAME
PATCH:
Only send NETDEV_CHANGEADDR notifies for address and broadcast changes.
Notify is also sent out if only one of the 2 changes is successful.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
--- linux-2.6.9-rc1-bk18.orig/net/core/rtnetlink.c 2004-09-11 16:30:30.000000000 +0200
+++ linux-2.6.9-rc1-bk18/net/core/rtnetlink.c 2004-09-11 23:30:05.000000000 +0200
@@ -265,7 +265,7 @@
struct ifinfomsg *ifm = NLMSG_DATA(nlh);
struct rtattr **ida = arg;
struct net_device *dev;
- int err;
+ int err, send_addr_notify = 0;
dev = dev_get_by_index(ifm->ifi_index);
if (!dev)
@@ -312,6 +312,7 @@
err = dev->set_mac_address(dev, RTA_DATA(ida[IFLA_ADDRESS - 1]));
if (err)
goto out;
+ send_addr_notify = 1;
}
if (ida[IFLA_BROADCAST - 1]) {
@@ -319,6 +320,7 @@
goto out;
memcpy(dev->broadcast, RTA_DATA(ida[IFLA_BROADCAST - 1]),
dev->addr_len);
+ send_addr_notify = 1;
}
if (ida[IFLA_MTU - 1]) {
@@ -365,7 +367,7 @@
err = 0;
out:
- if (!err)
+ if (send_addr_notify)
call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
dev_put(dev);
> Also note, the semantics of netlink are all-or-nothing transaction. i.e
> if one of the things requested for fails then you undo the rest. We can
> probably loosely say that unles the ATOMIC flag is set you dont need to
> undo that .. something to think about (summary is you probably dont want
> to send progress update to user space unless the transaction is
> successful; you however want to report progress of where failure happens
> - as we are discussing at the moment in the error code thread).
Agreed, I think undo should happen from user space though. In the
example of do_setlink, you can see that while it would be quite easy to
do the sanity checks before actually doing something you can't catch
all errors if you don't want to implement the name/mtu/addr change
routines yourself. Keeping in mind that those sanity checks will
probably only fail during the development of a application it doesn't
really help. That's why I implemented it this way.
I'm experimenting with a commit/fallback netlink library which basically
fetches the subject of change and stores the netlink message to be used
in case of fallback. NLM_F_ATOMIC makes it even more useable but is
quite expensive. A netlink change daemon would probably solve the
problem better.
next prev parent reply other threads:[~2004-09-11 22:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-10 19:50 [PATCH 2.6 NET] Device name changing via rtnetlink Jean Tourrilhes
2004-09-10 20:06 ` Thomas Graf
2004-09-10 20:13 ` Jean Tourrilhes
2004-09-10 20:22 ` Thomas Graf
2004-09-10 20:31 ` jamal
2004-09-10 20:32 ` Jean Tourrilhes
2004-09-10 20:43 ` Thomas Graf
2004-09-10 22:58 ` jamal
2004-09-10 23:17 ` Thomas Graf
2004-09-11 2:01 ` jamal
2004-09-11 13:44 ` Thomas Graf
2004-09-11 19:59 ` jamal
2004-09-11 22:06 ` Thomas Graf [this message]
2004-09-12 17:27 ` jamal
2004-09-13 0:20 ` David S. Miller
2004-09-10 23:04 ` David S. Miller
-- strict thread matches above, loose matches on Subject: below --
2004-09-10 13:36 Thomas Graf
2004-09-10 14:00 ` YOSHIFUJI Hideaki / 吉藤英明
2004-09-10 14:28 ` Thomas Graf
2004-09-10 14:31 ` YOSHIFUJI Hideaki / 吉藤英明
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=20040911220614.GF21181@postel.suug.ch \
--to=tgraf@suug.ch \
--cc=davem@davemloft.net \
--cc=hadi@cyberus.ca \
--cc=jt@hpl.hp.com \
--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).