From bdbec30a849807fb5e6841a38cfe0d168e5962b9 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Thu, 21 Dec 2023 12:06:05 +0100 Subject: 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 --- seitan.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'seitan.c') diff --git a/seitan.c b/seitan.c index fbfeb42..17ec63e 100644 --- a/seitan.c +++ b/seitan.c @@ -195,6 +195,24 @@ static int recvfd(int sockfd) return fd; } +static void gluten_relocate(struct gluten *g) +{ + unsigned i; + + for (i = 0; i < 256; i++) { + void **p; + + switch (g->header.relocation[i].type) { + case OFFSET_DATA: + p = gluten_write_ptr(g, g->header.relocation[i]); + *p = (intptr_t)*p + g->data; + break; + default: + ; + } + } +} + int main(int argc, char **argv) { char req_b[BUFSIZ]; @@ -212,11 +230,14 @@ int main(int argc, char **argv) arguments.uid = getuid(); arguments.gid = getgid(); parse(argc, argv, &arguments); + fd = open(arguments.input_file, O_CLOEXEC | O_RDONLY); if (read(fd, &g, sizeof(g)) != sizeof(g)) die("Failed to read gluten file"); close(fd); + gluten_relocate(&g); + if (arguments.pid > 0) { if ((pidfd = syscall(SYS_pidfd_open, arguments.pid, 0)) < 0) die(" pidfd_open"); -- cgit v1.2.3