odhcp6c: add -K option to set packet kernel priority
[project/odhcp6c.git] / src / dhcpv6.c
index 01bda16b0b8b0f9d27612ba1070205b7af12db2d..ca5957e3611c7d08ad0e6a6feba37ffea250dd93 100644 (file)
@@ -194,7 +194,7 @@ static char *dhcpv6_status_code_to_str(uint16_t code)
        return "Unknown";
 }
 
-int init_dhcpv6(const char *ifname, unsigned int options, int sol_timeout)
+int init_dhcpv6(const char *ifname, unsigned int options, int sk_prio, int sol_timeout)
 {
        client_options = options;
        dhcpv6_retx[DHCPV6_MSG_SOLICIT].max_timeo = sol_timeout;
@@ -289,6 +289,9 @@ int init_dhcpv6(const char *ifname, unsigned int options, int sol_timeout)
        if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, ifname, strlen(ifname)) < 0)
                goto failure;
 
+       if (setsockopt(sock, SOL_SOCKET, SO_PRIORITY, &sk_prio, sizeof(sk_prio)) < 0)
+               goto failure;
+
        struct sockaddr_in6 client_addr = { .sin6_family = AF_INET6,
                .sin6_port = htons(DHCPV6_CLIENT_PORT), .sin6_flowinfo = 0 };