From: Eric Dumazet <eric.dumazet@gmail.com>
To: "Erich E. Hoover" <ehoover@mines.edu>
Cc: Linux Netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH v2] Implement IP_UNICAST_IF socket option.
Date: Thu, 02 Feb 2012 23:45:44 +0100 [thread overview]
Message-ID: <1328222744.2480.38.camel@edumazet-laptop> (raw)
In-Reply-To: <CAEU2+vrgxzTmiHWs-kVoKeu2_DcFZQBjCXwQfQ8dms5O6+Larg@mail.gmail.com>
Le jeudi 02 février 2012 à 15:29 -0700, Erich E. Hoover a écrit :
> On Thu, Feb 2, 2012 at 2:57 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > Le jeudi 02 février 2012 à 14:36 -0700, Erich E. Hoover a écrit :
> > > ...
> > > + if (sk->sk_bound_dev_if && ifindex != sk->sk_bound_dev_if)
> > > + break;
> >
> > what happens if later sk_bound_dev_if is changed ? Should we redo the
> > above tests ?
>
> Would it be better if ip_default_ifindex performed the same comparison
> and prioritized the sk->sk_bound_dev_if value?
>
I guess you should mimic other OS behavior. Tests are probably needed.
> > > ...
> > > + case IP_UNICAST_IF:
> > > + {
> > > + __be32 iface;
> > > +
> > > + len = sizeof(__be32);
> > > + iface = htonl(inet->outif_index);
> > > + release_sock(sk);
> > > +
> > > + if (put_user(len, optlen))
> > > + return -EFAULT;
> > > + if (copy_to_user(optval, &iface, len))
> > > + return -EFAULT;
> > > + return 0;
> >
> > wow.... thats not pretty...
> >
> > what about :
> >
> > case IP_UNICASE_IF:
> > val = htonl(inet->outif_index);
> > break;
> >
>
> The return value needs to be 4 bytes even if sizeof(int) != 4.
>
On all arches supported by linux, sizeof(int) == 4
Maybe avoid sparse warning since val is not __be32
val = (__force int)htonl(inet->outif_index);
break;
> > > ...
> > IPv6 not supported ?
>
> Nope, at least according to the documentation the option is only for
> IPv4 (IPPROTO_IP).
Probably because of the mix on interface index and IPv4 addr on "other
OS".
But if we implement interface index only, it could be used on IPv6
too... I dont know...
next prev parent reply other threads:[~2012-02-02 22:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-02 21:36 [PATCH v2] Implement IP_UNICAST_IF socket option Erich E. Hoover
2012-02-02 21:57 ` Eric Dumazet
2012-02-02 22:29 ` Erich E. Hoover
2012-02-02 22:45 ` Eric Dumazet [this message]
2012-02-03 1:22 ` Erich E. Hoover
2012-02-03 1:51 ` David Miller
2012-02-03 10:01 ` Eric Dumazet
2012-02-03 15:21 ` Erich E. Hoover
2012-02-03 15:43 ` Eric Dumazet
2012-02-03 1:19 ` Xiaochun Lu
2012-02-03 1:38 ` Erich E. Hoover
2012-02-03 2:15 ` Xiaochun Lu
2012-02-03 1:50 ` David 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=1328222744.2480.38.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=ehoover@mines.edu \
--cc=netdev@vger.kernel.org \
/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