File: inet_ecn.h

package info (click to toggle)
openvswitch 2.6.2~pre%2Bgit20161223-3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 42,772 kB
  • ctags: 37,668
  • sloc: sh: 499,654; ansic: 261,360; xml: 21,326; python: 14,843; makefile: 450; perl: 409
file content (59 lines) | stat: -rw-r--r-- 1,326 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef _INET_ECN_WRAPPER_H_
#define _INET_ECN_WRAPPER_H_

#include_next <net/inet_ecn.h>

#define INET_ECN_decapsulate rpl_INET_ECN_decapsulate
static inline int INET_ECN_decapsulate(struct sk_buff *skb,
				       __u8 outer, __u8 inner)
{
	if (INET_ECN_is_not_ect(inner)) {
		switch (outer & INET_ECN_MASK) {
			case INET_ECN_NOT_ECT:
				return 0;
			case INET_ECN_ECT_0:
			case INET_ECN_ECT_1:
				return 1;
			case INET_ECN_CE:
				return 2;
		}
	}

	if (INET_ECN_is_ce(outer))
		INET_ECN_set_ce(skb);

	return 0;
}

#define IP_ECN_decapsulate rpl_IP_ECN_decapsulate
static inline int IP_ECN_decapsulate(const struct iphdr *oiph,
		struct sk_buff *skb)
{
	__u8 inner;

	if (skb->protocol == htons(ETH_P_IP))
		inner = ip_hdr(skb)->tos;
	else if (skb->protocol == htons(ETH_P_IPV6))
		inner = ipv6_get_dsfield(ipv6_hdr(skb));
	else
		return 0;

	return INET_ECN_decapsulate(skb, oiph->tos, inner);
}

#define IP6_ECN_decapsulate rpl_IP6_ECN_decapsulate
static inline int IP6_ECN_decapsulate(const struct ipv6hdr *oipv6h,
				      struct sk_buff *skb)
{
	__u8 inner;

	if (skb->protocol == htons(ETH_P_IP))
		inner = ip_hdr(skb)->tos;
	else if (skb->protocol == htons(ETH_P_IPV6))
		inner = ipv6_get_dsfield(ipv6_hdr(skb));
	else
		return 0;

	return INET_ECN_decapsulate(skb, ipv6_get_dsfield(oipv6h), inner);
}
#endif