• Brian Haley's avatar
    sockopt: Change getsockopt() of SO_BINDTODEVICE to return an interface name · c91f6df2
    Brian Haley authored
    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: default avatarBrian Haley <brian.haley@hp.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    c91f6df2
dev.c 166 KB