]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/net/gue.h
4 /* Definitions for the GUE header, standard and private flags, lengths
5 * of optional fields are below.
7 * Diagram of GUE header:
9 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
10 * |Ver|C| Hlen | Proto/ctype | Standard flags |P|
11 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
13 * ~ Fields (optional) ~
15 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
16 * | Private flags (optional, P bit is set) |
17 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
19 * ~ Private fields (optional) ~
21 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
23 * C bit indicates contol message when set, data message when unset.
24 * For a control message, proto/ctype is interpreted as a type of
25 * control message. For data messages, proto/ctype is the IP protocol
28 * P bit indicates private flags field is present. The private flags
29 * may refer to options placed after this field.
35 #if defined(__LITTLE_ENDIAN_BITFIELD)
39 #elif defined (__BIG_ENDIAN_BITFIELD)
44 #error "Please fix <asm/byteorder.h>"
53 /* Standard flags in GUE header */
55 #define GUE_FLAG_PRIV htons(1<<0) /* Private flags are in options */
56 #define GUE_LEN_PRIV 4
58 #define GUE_FLAGS_ALL (GUE_FLAG_PRIV)
60 /* Private flags in the private option extension */
62 #define GUE_PFLAG_REMCSUM htonl(1 << 31)
63 #define GUE_PLEN_REMCSUM 4
65 #define GUE_PFLAGS_ALL (GUE_PFLAG_REMCSUM)
67 /* Functions to compute options length corresponding to flags.
68 * If we ever have a lot of flags this can be potentially be
69 * converted to a more optimized algorithm (table lookup
72 static inline size_t guehdr_flags_len(__be16 flags
)
74 return ((flags
& GUE_FLAG_PRIV
) ? GUE_LEN_PRIV
: 0);
77 static inline size_t guehdr_priv_flags_len(__be32 flags
)
82 /* Validate standard and private flags. Returns non-zero (meaning invalid)
83 * if there is an unknown standard or private flags, or the options length for
84 * the flags exceeds the options length specific in hlen of the GUE header.
86 static inline int validate_gue_flags(struct guehdr
*guehdr
,
90 __be32 flags
= guehdr
->flags
;
92 if (flags
& ~GUE_FLAGS_ALL
)
95 len
= guehdr_flags_len(flags
);
99 if (flags
& GUE_FLAG_PRIV
) {
100 /* Private flags are last four bytes accounted in
103 flags
= *(__be32
*)((void *)&guehdr
[1] + len
- GUE_LEN_PRIV
);
105 if (flags
& ~GUE_PFLAGS_ALL
)
108 len
+= guehdr_priv_flags_len(flags
);