[Olsr-dev] [PATCH 1/1] Fix setsockopt for setting Traffic Class in IPv6
Ferry Huberts
(spam-protected)
Fri Apr 19 21:45:20 CEST 2013
Thanks,
Applied to
- release-0.6.5
- release-0.6.6
- master
On 19/04/13 18:51, (spam-protected) wrote:
> From: Ronald in 't Velt <(spam-protected)>
>
> HiOLSR-developers,
>
> For your consideration:
>
> Setting Traffic Class (the counterpart of TOS in IPv4) on OLSR IPv6 packets is currently broken.
> The code does not distinguish between the IPv4 and IPv6 cases, but it should, as the required
> 'level' and 'optname' arguments to setsockopt differ.
>
> I tested this patch by monitoring OLSR IPv6 packets with 'tcpdump -v': it appears to be working.
>
> Note this is for Linux only.
>
> This is my modest contribution to Dave Täht's quest to fix "TOS setting" in IPv6 :-)
> See: http://www.bufferbloat.net/issues/249
>
> Thanks,
> Ronald
>
> Signed-off-by: Ronald in 't Velt <(spam-protected)>
> ---
> src/unix/ifnet.c | 14 +++++++++++---
> 1 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/src/unix/ifnet.c b/src/unix/ifnet.c
> index 654c169..5ec8e32 100644
> --- a/src/unix/ifnet.c
> +++ b/src/unix/ifnet.c
> @@ -783,9 +783,17 @@ chk_if_up(struct olsr_if *iface, int debuglvl __attribute__ ((unused)))
> perror("setsockopt(SO_PRIORITY)");
> olsr_syslog(OLSR_LOG_ERR, "OLSRD: setsockopt(SO_PRIORITY) error %m");
> }
> - if (setsockopt(ifp->send_socket, IPPROTO_IP, IP_TOS, (char *)&tos_bits, sizeof(tos_bits)) < 0) {
> - perror("setsockopt(IP_TOS)");
> - olsr_syslog(OLSR_LOG_ERR, "setsockopt(IP_TOS) error %m");
> + if (olsr_cnf->ip_version == AF_INET) {
> + if (setsockopt(ifp->send_socket, IPPROTO_IP, IP_TOS, (char *)&tos_bits, sizeof(tos_bits)) < 0) {
> + perror("setsockopt(IP_TOS)");
> + olsr_syslog(OLSR_LOG_ERR, "setsockopt(IP_TOS) error %m");
> + }
> + } else {
> + /* IP version 6 */
> + if (setsockopt(ifp->send_socket, IPPROTO_IPV6, IPV6_TCLASS, (char *)&tos_bits, sizeof(tos_bits)) < 0) {
> + perror("setsockopt(IPV6_TCLASS)");
> + olsr_syslog(OLSR_LOG_ERR, "setsockopt(IPV6_TCLASS) error %m");
> + }
> }
> #endif /* __linux__ */
>
>
--
Ferry Huberts
More information about the Olsr-dev
mailing list