aboutgitcodelistschat:MatrixIRC
path: root/demo
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2023-12-21 12:06:05 +0100
committerStefano Brivio <sbrivio@redhat.com>2023-12-21 12:45:36 +0100
commitbdbec30a849807fb5e6841a38cfe0d168e5962b9 (patch)
tree210949d96b4d764235c1c5b81ad2eebb61681f95 /demo
parentc72c2493de8990c3a3b4780ec1429a3c359c121e (diff)
downloadseitan-bdbec30a849807fb5e6841a38cfe0d168e5962b9.tar
seitan-bdbec30a849807fb5e6841a38cfe0d168e5962b9.tar.gz
seitan-bdbec30a849807fb5e6841a38cfe0d168e5962b9.tar.bz2
seitan-bdbec30a849807fb5e6841a38cfe0d168e5962b9.tar.lz
seitan-bdbec30a849807fb5e6841a38cfe0d168e5962b9.tar.xz
seitan-bdbec30a849807fb5e6841a38cfe0d168e5962b9.tar.zst
seitan-bdbec30a849807fb5e6841a38cfe0d168e5962b9.zip
seitan: Add netlink, sendto()/sendmsg(), iovec handling, demo with routes
A bit rough at the moment, but it does the trick. Bonus: setsockopt() (with magic values only, not used in any demo yet). Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'demo')
-rw-r--r--demo/routes.hjson34
1 files changed, 34 insertions, 0 deletions
diff --git a/demo/routes.hjson b/demo/routes.hjson
new file mode 100644
index 0000000..5534001
--- /dev/null
+++ b/demo/routes.hjson
@@ -0,0 +1,34 @@
+[
+ {
+ "match": [
+ /* Is somebody trying to create a route? Hang on... */
+ { "sendmsg": { "fd": { "set": "fd" },
+ "msg": { "iov": { "set": "buf", "value": { "netlink": { "type": "newroute", "flags": { "all": [ "create", "request" ] } } } } } }
+ }
+ ],
+ "call": [
+ /* Create a new socket, owned by us */
+ { "socket": { "family": "netlink", "type": "raw", "flags": "nonblock", "protocol": "nl_route" }, "ret": "new_fd" },
+
+ /* Bind it for netlink usage */
+ { "bind": { "fd": { "get": "new_fd" }, "addr": { "family": "netlink", "pid": 0, "groups": 0 } }, "ret": "y" },
+
+ /* And re-send the original message */
+ { "sendmsg": { "fd": { "get": "new_fd" }, "msg": { "name": { "family": "netlink", "pid": 0, "groups": 0 }, "iovlen": 1, "iov": { "get": "buf" } }, "flags": 0 }, "ret": "n" }
+ ],
+ /* Then, sneak our socket back into the calling process */
+ "fd": { "src": { "get": "fd" }, "new": { "set": "new_fd" }, "close_on_exec": false },
+
+ /* And report success, or failure */
+ "return": { "value": "n", "error": "n" }
+ },
+ {
+ /* FIXME: Unblock subsequent recvmsg(). To keep this clean, we should proxy
+ * it ourselves.
+ */
+ "match": [
+ { "recvmsg": { "fd": 4 /* TODO: get *our* new number */ } }
+ ],
+ "return": { "value": 0, "error": 0 }
+ }
+]