diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-03-16 22:09:12 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-03-16 23:07:51 +0900 |
| commit | 72bd3fb05ef796e04e3b61015f6ffac3c1a937e3 (patch) | |
| tree | 1c842839af26daf68e7aa68d17b492835900594a /internal/netlink/rtnl_test.go | |
| parent | 59c66747dfb6647b28610ee13b122b1a927de08d (diff) | |
internal/netlink: generalise implementation from container
This is useful for uevent implementation.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/netlink/rtnl_test.go')
| -rw-r--r-- | internal/netlink/rtnl_test.go | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/internal/netlink/rtnl_test.go b/internal/netlink/rtnl_test.go new file mode 100644 index 00000000..8a281a46 --- /dev/null +++ b/internal/netlink/rtnl_test.go @@ -0,0 +1,62 @@ +package netlink + +import ( + "syscall" + "testing" +) + +func TestPayloadRTNETLINK(t *testing.T) { + t.Parallel() + + checkPayload(t, []payloadTestCase{ + {"RTM_NEWADDR lo", func(c *conn) { + (&RouteConn{c}).writeNewaddrLo(1) + }, []byte{ + /* Len */ 0x28, 0, 0, 0, + /* Type */ 0x14, 0, + /* Flags */ 5, 6, + /* Seq */ 0, 0, 0, 0, + /* Pid */ 1, 0, 0, 0, + + /* Family */ 2, + /* Prefixlen */ 8, + /* Flags */ 0x80, + /* Scope */ 0xfe, + /* Index */ 1, 0, 0, 0, + + /* Len */ 8, 0, + /* Type */ 2, 0, + /* in_addr */ 127, 0, 0, 1, + + /* Len */ 8, 0, + /* Type */ 1, 0, + /* in_addr */ 127, 0, 0, 1, + }}, + + {"RTM_NEWLINK", func(c *conn) { + c.seq++ + (&RouteConn{c}).writeIfInfomsg( + syscall.RTM_NEWLINK, 0, + &syscall.IfInfomsg{ + Family: syscall.AF_UNSPEC, + Index: 1, + Flags: syscall.IFF_UP, + Change: syscall.IFF_UP, + }, + ) + }, []byte{ + /* Len */ 0x20, 0, 0, 0, + /* Type */ 0x10, 0, + /* Flags */ 5, 0, + /* Seq */ 1, 0, 0, 0, + /* Pid */ 1, 0, 0, 0, + + /* Family */ 0, + /* pad */ 0, + /* Type */ 0, 0, + /* Index */ 1, 0, 0, 0, + /* Flags */ 1, 0, 0, 0, + /* Change */ 1, 0, 0, 0, + }}, + }) +} |
