]> git.baikalelectronics.ru Git - kernel.git/commit
sockopt: Change getsockopt() of SO_BINDTODEVICE to return an interface name
authorBrian Haley <brian.haley@hp.com>
Mon, 26 Nov 2012 05:21:08 +0000 (05:21 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 26 Nov 2012 22:22:14 +0000 (17:22 -0500)
commit94f1b8ab8fcc4410331e0f3b4083c03192620d16
treecd29f1a068154e6136e54449ed7caa0b2f922318
parent5e5265709608a1083bdf8cd8534c2f4820081578
sockopt: Change getsockopt() of SO_BINDTODEVICE to return an interface name

Instead of having the getsockopt() of SO_BINDTODEVICE return an index, which
will then require another call like if_indextoname() to get the actual interface
name, have it return the name directly.

This also matches the existing man page description on socket(7) which mentions
the argument being an interface name.

If the value has not been set, zero is returned and optlen will be set to zero
to indicate there is no interface name present.

Added a seqlock to protect this code path, and dev_ifname(), from someone
changing the device name via dev_change_name().

v2: Added seqlock protection while copying device name.

v3: Fixed word wrap in patch.

Signed-off-by: Brian Haley <brian.haley@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netdevice.h
net/core/dev.c
net/core/sock.c