All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2] ipmaddr: use preferred_family when given
@ 2018-08-15 23:08 Mahesh Bandewar
  2018-08-17 16:29 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Mahesh Bandewar @ 2018-08-15 23:08 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, Mahesh Bandewar

From: Mahesh Bandewar <maheshb@google.com>

When creating socket() AF_INET is used irrespective of the family
that is given at the command-line (with -4, -6, or -0). This change
will open the socket with the preferred family.

Signed-off-by: Mahesh Bandewar <maheshb@google.com>
---
 ip/ipmaddr.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/ip/ipmaddr.c b/ip/ipmaddr.c
index a48499029e17..abf83784d0df 100644
--- a/ip/ipmaddr.c
+++ b/ip/ipmaddr.c
@@ -289,6 +289,7 @@ static int multiaddr_list(int argc, char **argv)
 static int multiaddr_modify(int cmd, int argc, char **argv)
 {
 	struct ifreq ifr = {};
+	int family;
 	int fd;
 
 	if (cmd == RTM_NEWADDR)
@@ -324,7 +325,17 @@ static int multiaddr_modify(int cmd, int argc, char **argv)
 		exit(-1);
 	}
 
-	fd = socket(AF_INET, SOCK_DGRAM, 0);
+	switch (preferred_family) {
+	case AF_INET6:
+	case AF_PACKET:
+	case AF_INET:
+		family = preferred_family;
+		break;
+	default:
+		family = AF_INET;
+	}
+
+	fd = socket(family, SOCK_DGRAM, 0);
 	if (fd < 0) {
 		perror("Cannot create socket");
 		exit(1);
-- 
2.18.0.865.gffc8e1a3cd6-goog

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2] ipmaddr: use preferred_family when given
  2018-08-15 23:08 [PATCH iproute2] ipmaddr: use preferred_family when given Mahesh Bandewar
@ 2018-08-17 16:29 ` Stephen Hemminger
  2018-08-17 17:19   ` Mahesh Bandewar (महेश बंडेवार)
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2018-08-17 16:29 UTC (permalink / raw)
  To: Mahesh Bandewar; +Cc: netdev, Mahesh Bandewar

On Wed, 15 Aug 2018 16:08:55 -0700
Mahesh Bandewar <mahesh@bandewar.net> wrote:

> From: Mahesh Bandewar <maheshb@google.com>
> 
> When creating socket() AF_INET is used irrespective of the family
> that is given at the command-line (with -4, -6, or -0). This change
> will open the socket with the preferred family.
> 
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>
> ---
>  ip/ipmaddr.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)

What is impact of this? Does ip multicast address changes not work on IPv6?
Or is it just doing the right thing?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2] ipmaddr: use preferred_family when given
  2018-08-17 16:29 ` Stephen Hemminger
@ 2018-08-17 17:19   ` Mahesh Bandewar (महेश बंडेवार)
  0 siblings, 0 replies; 3+ messages in thread
From: Mahesh Bandewar (महेश बंडेवार) @ 2018-08-17 17:19 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Mahesh Bandewar, netdev

On Fri, Aug 17, 2018 at 9:29 AM, Stephen Hemminger
<stephen@networkplumber.org> wrote:
> On Wed, 15 Aug 2018 16:08:55 -0700
> Mahesh Bandewar <mahesh@bandewar.net> wrote:
>
>> From: Mahesh Bandewar <maheshb@google.com>
>>
>> When creating socket() AF_INET is used irrespective of the family
>> that is given at the command-line (with -4, -6, or -0). This change
>> will open the socket with the preferred family.
>>
>> Signed-off-by: Mahesh Bandewar <maheshb@google.com>
>> ---
>>  ip/ipmaddr.c | 13 ++++++++++++-
>>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> What is impact of this? Does ip multicast address changes not work on IPv6?
> Or is it just doing the right thing?
Essentially a no-op. Just doing the right thing. :)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-17 20:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-15 23:08 [PATCH iproute2] ipmaddr: use preferred_family when given Mahesh Bandewar
2018-08-17 16:29 ` Stephen Hemminger
2018-08-17 17:19   ` Mahesh Bandewar (महेश बंडेवार)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.