Skip to content

Commit

Permalink
cli/run: set IP free bind
Browse files Browse the repository at this point in the history
Sometimes Mimic and UDP services are in separate nodes, and enabling IP{,V6}_FREEBIND will allow control packet to be sent on behalf of UDP services.

Fixes #7.
  • Loading branch information
hack3ric committed Dec 3, 2024
1 parent 3d54132 commit 118677f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ static int handle_send_ctrl_packet(struct send_options* s, const char* ifname) {
// and they will be forwarded to the socket and discarded anyway.
_cleanup_fd int sk = try(socket(ip_proto(&s->conn.local), SOCK_RAW | SOCK_NONBLOCK, IPPROTO_TCP));

int level = SOL_IP, opt = IP_FREEBIND, yes = 1;
if (ip_proto(&s->conn.local) == AF_INET6) {
level = SOL_IPV6;
opt = IPV6_FREEBIND;
}
try(setsockopt(sk, level, opt, &yes, sizeof(yes)), _("failed to set IP free bind: %s"),
strret);

struct sockaddr_storage saddr, daddr;
conn_tuple_to_addrs(&s->conn, &saddr, &daddr);

Expand Down

0 comments on commit 118677f

Please sign in to comment.