Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b9d85cd
Add addr to interface as CIDR
saminiir Mar 8, 2019
b390243
Add exit_with_error macro
saminiir Mar 8, 2019
e2cb38e
Make code blocks in README easier to copy
saminiir Mar 8, 2019
37950a3
Support NETLINK socket type in liblevelip
saminiir Mar 9, 2019
2cff64b
Start adding AF_NETLINK socket type
saminiir Mar 9, 2019
5bea9bf
Add `bind` syscall
saminiir Mar 9, 2019
8c7b80f
Add sendmsg recvmsg placeholders
saminiir Mar 9, 2019
cb3b387
Start adding sendmsg mocked syscall
saminiir Mar 11, 2019
1623c79
Start implementing Netlink & sock_diag API
saminiir Mar 17, 2019
e15d0b3
Start implementing recvmsg
saminiir Mar 17, 2019
4543798
Mock recvmsg MSG_DONE
saminiir Mar 26, 2019
fa0a651
Support MSG_PEEK in recvmsg
saminiir Mar 29, 2019
ad680cc
Improve recvmsg debug prints
saminiir Mar 29, 2019
6779d90
Set Netlink pid to 0 for kernel-like communication
saminiir Mar 31, 2019
06da9ff
Do not take a pointer to packed struct member
saminiir Mar 31, 2019
589076e
Add Troubleshooting to getting-started document
saminiir Mar 31, 2019
e3c7282
Add "dummy" protocol for TCP
saminiir Apr 1, 2019
95984d4
Store Netlink messages to a list
saminiir Apr 3, 2019
69c6a6a
Find socket's netlink request from list
saminiir Apr 4, 2019
ec0bcd3
Add stub function for demuxing netlink request
saminiir Apr 4, 2019
59fc461
Start demuxing Netlink request into response
saminiir Apr 5, 2019
52c239b
Implement basic Netlink socket filtering callback
saminiir Apr 9, 2019
dff7272
Free allocated sock_diag memory properly
saminiir Apr 10, 2019
b4fd720
Consume Netlink request after use
saminiir Apr 12, 2019
894d7b1
Make `ss` print proper idiag_state
saminiir Apr 12, 2019
4ba8702
Grab proper port and address info from TCPv4 socket
saminiir Apr 23, 2019
4220ab6
Use socket type for filtering
saminiir Apr 25, 2019
c84b0ca
Add note about possible false deadlock detected by TSan
saminiir Apr 25, 2019
3fa611c
Delete debug printfs
saminiir Apr 26, 2019
e6f531f
Start as root but change to uid `nobody` before starting stack
saminiir Apr 26, 2019
72e4c27
Killall lvl-ip processes after test suite
saminiir Apr 26, 2019
b7f38f8
Print lvl-ip logs on test failure
saminiir Apr 28, 2019
f9d118f
Manually create tap device
saminiir May 8, 2019
34b227c
Revert "Killall lvl-ip processes after test suite"
saminiir May 8, 2019
9b7d7aa
Add more descriptive error messages on IPC socket init errors
saminiir May 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add exit_with_error macro
  • Loading branch information
saminiir committed Mar 8, 2019
commit b39024388cec087a7792314b926a8cfdcb9c48f4
3 changes: 3 additions & 0 deletions include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#define print_err(str, ...) \
fprintf(stderr, str, ##__VA_ARGS__);

#define exit_with_error(en, msg) \
do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)

int run_cmd(char *cmd, ...);
uint32_t sum_every_16bits(void *addr, int count);
uint16_t checksum(void *addr, int count, int start_sum);
Expand Down
37 changes: 13 additions & 24 deletions src/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,47 +476,36 @@ void *start_ipc_listener()
}

if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
perror("IPC listener UNIX socket");
exit(EXIT_FAILURE);
exit_with_error(fd, "IPC listener UNIX socket");
}

memset(&un, 0, sizeof(struct sockaddr_un));
un.sun_family = AF_UNIX;
strncpy(un.sun_path, sockname, sizeof(un.sun_path) - 1);

rc = bind(fd, (const struct sockaddr *) &un, sizeof(struct sockaddr_un));

if (rc == -1) {
perror("IPC bind");
exit(EXIT_FAILURE);
if ((rc = bind(fd, (const struct sockaddr *) &un, sizeof(struct sockaddr_un))) == -1) {
exit_with_error(rc, "IPC bind");
}

rc = listen(fd, 20);

if (rc == -1) {
perror("IPC listen");
exit(EXIT_FAILURE);
if ((rc = listen(fd, 20)) == -1) {
exit_with_error(rc, "IPC listen");
}

if (chmod(sockname, S_IRUSR | S_IWUSR | S_IXUSR |
S_IRGRP | S_IWGRP | S_IXGRP |
S_IROTH | S_IWOTH | S_IXOTH) == -1) {
perror("Chmod on lvl-ip IPC UNIX socket failed");
exit(EXIT_FAILURE);
if ((rc = chmod(sockname, S_IRUSR | S_IWUSR | S_IXUSR |
S_IRGRP | S_IWGRP | S_IXGRP |
S_IROTH | S_IWOTH | S_IXOTH)) == -1) {
exit_with_error(rc, "Chmod on lvl-ip IPC UNIX socket failed");
}

for (;;) {
datasock = accept(fd, NULL, NULL);
if (datasock == -1) {
perror("IPC accept");
exit(EXIT_FAILURE);
if ((datasock = accept(fd, NULL, NULL)) == -1) {
exit_with_error(datasock ,"IPC accept");
}

struct ipc_thread *th = ipc_alloc_thread(datasock);

if (pthread_create(&th->id, NULL, &socket_ipc_open, &th->sock) != 0) {
print_err("Error on socket thread creation\n");
exit(1);
if ((rc = pthread_create(&th->id, NULL, &socket_ipc_open, &th->sock)) != 0) {
exit_with_error(rc, "Error on socket thread creation");
};
}

Expand Down