diff options
author | Fabricio Voznika <fvoznika@google.com> | 2018-08-08 22:38:41 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-08-08 22:39:58 -0700 |
commit | 4e171f7590284c1f4cedf90c92204873961b2e97 (patch) | |
tree | 98fef86694288ce258985ce7ff4772ee23566874 /pkg/sentry/socket/netlink/route | |
parent | 48b5b35b2bd46ecd043f95d5f470da71046af760 (diff) |
Basic support for ip link/addr and ifconfig
Closes #94
PiperOrigin-RevId: 207997580
Change-Id: I19b426f1586b5ec12f8b0cd5884d5b401d334924
Diffstat (limited to 'pkg/sentry/socket/netlink/route')
-rw-r--r-- | pkg/sentry/socket/netlink/route/protocol.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/pkg/sentry/socket/netlink/route/protocol.go b/pkg/sentry/socket/netlink/route/protocol.go index 55a76e916..70322b9ed 100644 --- a/pkg/sentry/socket/netlink/route/protocol.go +++ b/pkg/sentry/socket/netlink/route/protocol.go @@ -16,6 +16,8 @@ package route import ( + "bytes" + "gvisor.googlesource.com/gvisor/pkg/abi/linux" "gvisor.googlesource.com/gvisor/pkg/sentry/context" "gvisor.googlesource.com/gvisor/pkg/sentry/inet" @@ -97,9 +99,18 @@ func (p *Protocol) dumpLinks(ctx context.Context, hdr linux.NetlinkMessageHeader }) m.PutAttrString(linux.IFLA_IFNAME, i.Name) + m.PutAttr(linux.IFLA_MTU, i.MTU) + + mac := make([]byte, 6) + brd := mac + if len(i.Addr) > 0 { + mac = i.Addr + brd = bytes.Repeat([]byte{0xff}, len(i.Addr)) + } + m.PutAttr(linux.IFLA_ADDRESS, mac) + m.PutAttr(linux.IFLA_BROADCAST, brd) - // TODO: There are many more attributes, such as - // MAC address. + // TODO: There are many more attributes. } return nil |