10 Commits

Author SHA1 Message Date
Jing Chen 35d3c6eb73 Update MTU value for ethernet devices.
L2 MTU includes both payload and ethernet header. gVisor has supported setting
data link layer MTU, it will be  up to users to set up proper value for a
device's MTU if a larger value is expected.

By doing the change, gVisor will be consistent with runc:

```shell
# runc
root@cec4d7238802:/# ip link set dev lo mtu 1234
root@cec4d7238802:/# ip link list dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 1234 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

# runsc before the change.
root@7cd89278d414:/# ip link set dev lo mtu 1234
root@7cd89278d414:/# ip link list dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 1220
    link/loopback 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff

# runsc after the change.
root@e811c5851226:/# ip link set dev lo mtu 1234
root@e811c5851226:/# ip link list dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 1234
    link/loopback 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
```
PiperOrigin-RevId: 684746090
2024-10-11 01:36:07 -07:00
Jing Chen 5e8dd6482c Disallow setting a coordinator for a coordinator device.
The error code is based on the runc's behavior:

```shell
# ip link set dev br0 master br0
Error: Can not enslave a bridge to a bridge.
# echo $?
2
```

Reported-by: syzbot+9dcefbdcc9ecdeb4df96@syzkaller.appspotmail.com
PiperOrigin-RevId: 679761515
2024-09-27 16:13:45 -07:00
Jing Chen f681bcc095 Implement RTM_DELROUTE in netstack.
PiperOrigin-RevId: 675711612
2024-09-17 14:33:41 -07:00
Jing Chen 35309c96c0 Implement RTM_NEWROUTE in netstack to create/replace a route.
PiperOrigin-RevId: 650814137
2024-07-09 18:04:19 -07:00
Jing Chen 096478a2ff Fix the MAC address parse in IFLA_ADDRESS and add the tests.
PiperOrigin-RevId: 650333797
2024-07-08 12:19:08 -07:00
Andrei Vagin b488752cba netstack: implement RTM_SETLINK/IFLA_NET_NS_FD
IFLA_NET_NS_FD specifies a file descriptor that refers to a network namespace.

PiperOrigin-RevId: 648882826
2024-07-02 16:49:27 -07:00
Jing Chen 5e89d40761 Test renaming a link name in setlink_test.sh
PiperOrigin-RevId: 648834200
2024-07-02 14:01:51 -07:00
Jing Chen 6dd4ef415b Implement IFLA_MTU which changes a link's MTU.
PiperOrigin-RevId: 648618069
2024-07-02 00:36:40 -07:00
Jing Chen 59adcc9b1e 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
2024-06-28 17:02:31 -07:00
Andrei Vagin c3fe152a48 test: add the rtnetlink test suit
It is much easier to create complex configurations from bash scripts with help
of the iproute2 tools.

PiperOrigin-RevId: 646286415
2024-06-24 18:25:26 -07:00