From: Julian Anastasov <ja@ssi.bg>
To: Vincent Li <vincent.mc.li@gmail.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
linux-kernel@vger.kernel.org, davem@davemloft.net
Subject: Re: [PATCH] Allow userspace code to use flag IFA_F_SECONDARY to specify an ip address to be primary or secondary ip on an interface
Date: Fri, 27 Sep 2013 22:26:29 +0300 (EEST) [thread overview]
Message-ID: <alpine.LFD.2.00.1309272221210.1725@ja.ssi.bg> (raw)
In-Reply-To: <CAK3+h2wYw92KR-Bzxesb5hNW2ua4GmVLeywJ__uPyqMW-+p8pA@mail.gmail.com>
Hello,
On Wed, 25 Sep 2013, Vincent Li wrote:
> I think it is good idea to add these preferences flags and sorted
> them, but my code knowledge is limited to implement it as I am still
> learning, I can help testing :)
I can try it, if such idea looks good enough to
others.
> On Wed, Sep 25, 2013 at 12:08 AM, Julian Anastasov <ja@ssi.bg> wrote:
>
> > My first idea was to use NLM_F_APPEND to implement
> > 'ip addr prepend' and 'ip addr append' but the default
> > operation is 'append' without providing NLM_F_APPEND, so it
> > does not work.
> >
> > Another idea is to add new attribute IFA_PREFERENCE in
> > include/uapi/linux/if_addr.h just before __IFA_MAX, integer,
> > 3 of the values are known. A preference for the used scope.
> >
> > /* Add as last, default */
> > IFA_PREFERENCE_APPEND = 0,
> >
> > /* Add as last primary, before any present primary in subnet */
> > IFA_PREFERENCE_PRIMARY = 128,
> >
> > /* First for scope */
> > IFA_PREFERENCE_FIRST = 255,
> >
> > We should keep it in ifa as priority, for
> > sorting purposes. It can be 4-byte value, if user wants
> > to copy user-defined order into preference.
> >
> > Sorting order should be:
> >
> > - all primaries sorted by decreasing scope, decreasing
> > priority and adding order
> >
> > - then all secondaries (IFA_F_SECONDARY) sorted by decreasing
> > priority and adding order
> >
> > Usage:
> >
> > ip addr add ... pref[erence] type_or_priority
> >
> > # Add floating IP (append at priority 128)
> > # The primary mode is not guaranteed if another address from
> > # the same subnet is already using the same or higher priority.
> > ip addr add ... pref primary
> > # More preferred primary
> > ip addr add ... pref 129
> >
> > # Add first IP for scope
> > ip addr add ... pref first
> >
> > The scope has similar 'sorting' property but not
> > for IPs in same subnet and it would be difficult to use
> > it for global routes.
> >
> > Thoughts?
Regards
--
Julian Anastasov <ja@ssi.bg>
prev parent reply other threads:[~2013-09-27 19:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-24 18:11 Vincent Li
2013-09-24 19:21 ` Stephen Hemminger
2013-09-24 19:28 ` David Miller
2013-09-24 20:46 ` Vincent Li
2013-09-24 21:13 ` Julian Anastasov
2013-09-24 21:34 ` Vincent Li
2013-09-24 21:54 ` Vincent Li
2013-09-25 7:08 ` Julian Anastasov
2013-09-25 17:30 ` Vincent Li
2013-09-27 19:26 ` Julian Anastasov [this message]
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=alpine.LFD.2.00.1309272221210.1725@ja.ssi.bg \
--to=ja@ssi.bg \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vincent.mc.li@gmail.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
all inboxes | Powered by JetHome®