Fix the MAC address parse in IFLA_ADDRESS and add the tests.

PiperOrigin-RevId: 650333797
This commit is contained in:
Jing Chen
2024-07-08 12:19:08 -07:00
committed by gVisor bot
parent 3e875a5dad
commit 096478a2ff
7 changed files with 106 additions and 8 deletions
+2 -2
View File
@@ -206,10 +206,10 @@ func (s *Stack) setLink(ctx context.Context, id tcpip.NICID, linkAttrs map[uint1
}
}
case linux.IFLA_ADDRESS:
addr, err := tcpip.ParseMACAddress(v.String())
if err != nil {
if len(v) != tcpip.LinkAddressSize {
return syserr.ErrInvalidArgument
}
addr := tcpip.LinkAddress(v)
if err := s.Stack.SetNICAddress(id, addr); err != nil {
return syserr.TranslateNetstackError(err)
}