mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Implement IFLA_IFNAME which specifies an interface's name.
IFLA_IFNAME is used to set an interface's name when being used with RTM_NEWLINK and RTM_SETLINK. RTM_NEWLINK is the preferred way, it is backwards compatible with RTM_SETLINK. For gVisor, when RTM_SETLINK is introduced, it shall just share the implementation. PiperOrigin-RevId: 647833657
This commit is contained in:
@@ -123,15 +123,13 @@ func (s *Stack) SetInterface(ctx context.Context, msg *nlmsg.Message) *syserr.Er
|
||||
if len(value) < 1 {
|
||||
return syserr.ErrInvalidArgument
|
||||
}
|
||||
if ifinfomsg.Index != 0 {
|
||||
// Device name changing isn't supported yet.
|
||||
return syserr.ErrNotSupported
|
||||
}
|
||||
ifname = value.String()
|
||||
for idx, ifa := range s.Interfaces() {
|
||||
if ifname == ifa.Name {
|
||||
ifinfomsg.Index = idx
|
||||
break
|
||||
if ifinfomsg.Index == 0 {
|
||||
ifname = value.String()
|
||||
for idx, ifa := range s.Interfaces() {
|
||||
if ifname == ifa.Name {
|
||||
ifinfomsg.Index = idx
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
case linux.IFLA_MASTER:
|
||||
@@ -190,6 +188,10 @@ func (s *Stack) setLink(id tcpip.NICID, linkAttrs map[uint16]nlmsg.BytesView) *s
|
||||
if err := s.Stack.SetNICAddress(id, addr); err != nil {
|
||||
return syserr.TranslateNetstackError(err)
|
||||
}
|
||||
case linux.IFLA_IFNAME:
|
||||
if err := s.Stack.SetNICName(id, v.String()); err != nil {
|
||||
return syserr.TranslateNetstackError(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user