Hi,
On Tue, 7 Feb 2023 at 13:53, Clément Péron <[email protected]> wrote: > > Some ISP, like the French ISP Orange uses DHCP messages with > a CoS Priority of 6 otherwise they are not processed. > > Add an option to allow setting this property. > > Signed-off-by: Clément Péron <[email protected]> Sorry, unwanted resend. I have properly configured my mail client on a new computer and pending emails have been flushed out. Please ignore, Clement > --- > networking/udhcp/d6_dhcpc.c | 6 ++++++ > networking/udhcp/d6_packet.c | 14 ++++++++++++++ > networking/udhcp/dhcpc.c | 10 ++++++++++ > networking/udhcp/dhcpc.h | 2 ++ > networking/udhcp/packet.c | 16 ++++++++++++++++ > 5 files changed, 48 insertions(+) > > diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c > index cdd06188e..675914432 100644 > --- a/networking/udhcp/d6_dhcpc.c > +++ b/networking/udhcp/d6_dhcpc.c > @@ -129,6 +129,7 @@ static const char udhcpc6_longopts[] ALIGN1 = > ) > /// IF_FEATURE_UDHCPC_ARPING("arping\0" No_argument "a") > IF_FEATURE_UDHCP_PORT("client-port\0" Required_argument "P") > + IF_FEATURE_UDHCPC_COS("cos\0" Required_argument "y") > ; > #endif > /* Must match getopt32 option string order */ > @@ -1153,6 +1154,9 @@ static void client_background(void) > ////usage: IF_FEATURE_UDHCPC_ARPING( > ////usage: "\n -a Use arping to validate offered > address" > ////usage: ) > +//usage: IF_FEATURE_UDHCPC_COS( > +//usage: "\n -y PRIORITY CoS value 0 .. 7, default 0" > +//usage: ) > //usage: "\n -l Send 'information request' instead of > 'solicit'" > //usage: "\n (used for servers which do not assign > IPv6 addresses)" > //usage: "\n -r IPv6 Request this address ('no' to not > request any IP)" > @@ -1214,6 +1218,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) > USE_FOR_MMU("b") > ///IF_FEATURE_UDHCPC_ARPING("a") > IF_FEATURE_UDHCP_PORT("P:") > + IF_FEATURE_UDHCPC_COS("y:+") > "v" > "\0" IF_UDHCP_VERBOSE("vv") /* -v is a counter */ > , udhcpc6_longopts > @@ -1223,6 +1228,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) > , &list_O > , &list_x > IF_FEATURE_UDHCP_PORT(, &str_P) > + IF_FEATURE_UDHCPC_COS(, &sk_prio) > IF_UDHCP_VERBOSE(, &dhcp_verbose) > ); > requested_ipv6 = NULL; > diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c > index 142de9b43..cbe589ff7 100644 > --- a/networking/udhcp/d6_packet.c > +++ b/networking/udhcp/d6_packet.c > @@ -68,6 +68,13 @@ int FAST_FUNC d6_send_raw_packet_from_client_data_ifindex( > goto ret_msg; > } > > + IF_FEATURE_UDHCPC_COS( > + if (sk_prio) { > + if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &sk_prio, > sizeof(sk_prio))) { > + log1s("raw: SO_PRIORITY setsockopt() failed"); > + } > + }) > + > memset(&dest_sll, 0, sizeof(dest_sll)); > memset(&packet, 0, offsetof(struct ip6_udp_d6_packet, data)); > packet.data = *d6_pkt; /* struct copy */ > @@ -153,6 +160,13 @@ int FAST_FUNC > d6_send_kernel_packet_from_client_data_ifindex( > } > setsockopt_reuseaddr(fd); > > + IF_FEATURE_UDHCPC_COS( > + if (sk_prio) { > + if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &sk_prio, > sizeof(sk_prio))) { > + log1s("raw: SO_PRIORITY setsockopt() failed"); > + } > + }) > + > memset(&sa, 0, sizeof(sa)); > sa.sin6_family = AF_INET6; > sa.sin6_port = htons(source_port); > diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c > index c757fb37c..610bec427 100644 > --- a/networking/udhcp/dhcpc.c > +++ b/networking/udhcp/dhcpc.c > @@ -1085,6 +1085,13 @@ static int udhcp_raw_socket(int ifindex) > } > #endif > > +IF_FEATURE_UDHCPC_COS( > + if (sk_prio) { > + if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &sk_prio, > sizeof(sk_prio))) { > + log1s("raw: SO_PRIORITY setsockopt() failed"); > + } > + }) > + > if (setsockopt_1(fd, SOL_PACKET, PACKET_AUXDATA) != 0) { > if (errno != ENOPROTOOPT) > log1s("can't set PACKET_AUXDATA on raw socket"); > @@ -1186,6 +1193,9 @@ static void client_background(void) > //usage: IF_FEATURE_UDHCPC_ARPING( > //usage: "\n -a[MSEC] Validate offered address with ARP > ping" > //usage: ) > +//usage: IF_FEATURE_UDHCPC_COS( > +//usage: "\n -y PRIORITY CoS value 0 .. 7, default 0" > +//usage: ) > //usage: "\n -r IP Request this IP address" > //usage: "\n -o Don't request any options (unless -O > is given)" > //usage: "\n -O OPT Request option OPT from server > (cumulative)" > diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h > index 19b054b32..171f70d7c 100644 > --- a/networking/udhcp/dhcpc.h > +++ b/networking/udhcp/dhcpc.h > @@ -7,6 +7,8 @@ > > PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN > > +IF_FEATURE_UDHCPC_COS(extern uint32_t sk_prio;) > + > struct client_data_t { > uint8_t client_mac[6]; /* Our mac address */ > IF_FEATURE_UDHCP_PORT(uint16_t port;) > diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c > index 529978189..4cc70ba52 100644 > --- a/networking/udhcp/packet.c > +++ b/networking/udhcp/packet.c > @@ -12,6 +12,8 @@ > #include <netinet/if_ether.h> > #include <netpacket/packet.h> > > +IF_FEATURE_UDHCPC_COS(uint32_t sk_prio;) > + > #if ENABLE_UDHCPC || ENABLE_UDHCPD > void FAST_FUNC udhcp_init_header(struct dhcp_packet *packet, char type) > { > @@ -121,6 +123,13 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet > *dhcp_pkt, > goto ret_msg; > } > > + IF_FEATURE_UDHCPC_COS( > + if (sk_prio) { > + if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &sk_prio, > sizeof(sk_prio))) { > + log1s("raw: SO_PRIORITY setsockopt() failed"); > + } > + }) > + > memset(&dest_sll, 0, sizeof(dest_sll)); > memset(&packet, 0, offsetof(struct ip_udp_dhcp_packet, data)); > packet.data = *dhcp_pkt; /* struct copy */ > @@ -207,6 +216,13 @@ int FAST_FUNC udhcp_send_kernel_packet(struct > dhcp_packet *dhcp_pkt, > } > setsockopt_reuseaddr(fd); > > + IF_FEATURE_UDHCPC_COS( > + if (sk_prio) { > + if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &sk_prio, > sizeof(sk_prio))) { > + log1s("raw: SO_PRIORITY setsockopt() failed"); > + } > + }) > + > /* If interface carrier goes down, unless we > * bind socket to a particular netdev, the packet > * can go out through another interface, eg. via > -- > 2.37.1 (Apple Git-137.1) > _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
