~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/net/gue.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/net/gue.h (Version linux-6.11.5) and /include/net/gue.h (Version linux-5.10.228)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __NET_GUE_H                                 2 #ifndef __NET_GUE_H
  3 #define __NET_GUE_H                                 3 #define __NET_GUE_H
  4                                                     4 
  5 /* Definitions for the GUE header, standard an      5 /* Definitions for the GUE header, standard and private flags, lengths
  6  * of optional fields are below.                    6  * of optional fields are below.
  7  *                                                  7  *
  8  * Diagram of GUE header:                           8  * Diagram of GUE header:
  9  *                                                  9  *
 10  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+     10  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 11  * |Ver|C|  Hlen   | Proto/ctype   |        St     11  * |Ver|C|  Hlen   | Proto/ctype   |        Standard flags       |P|
 12  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+     12  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 13  * |                                               13  * |                                                               |
 14  * ~                      Fields (optional)        14  * ~                      Fields (optional)                        ~
 15  * |                                               15  * |                                                               |
 16  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+     16  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 17  * |            Private flags (optional, P bit     17  * |            Private flags (optional, P bit is set)             |
 18  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+     18  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 19  * |                                               19  * |                                                               |
 20  * ~                   Private fields (optiona     20  * ~                   Private fields (optional)                   ~
 21  * |                                               21  * |                                                               |
 22  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+     22  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 23  *                                                 23  *
 24  * C bit indicates control message when set, d     24  * C bit indicates control message when set, data message when unset.
 25  * For a control message, proto/ctype is inter     25  * For a control message, proto/ctype is interpreted as a type of
 26  * control message. For data messages, proto/c     26  * control message. For data messages, proto/ctype is the IP protocol
 27  * of the next header.                             27  * of the next header.
 28  *                                                 28  *
 29  * P bit indicates private flags field is pres     29  * P bit indicates private flags field is present. The private flags
 30  * may refer to options placed after this fiel     30  * may refer to options placed after this field.
 31  */                                                31  */
 32                                                    32 
 33 #include <asm/byteorder.h>                     << 
 34 #include <linux/types.h>                       << 
 35                                                << 
 36 struct guehdr {                                    33 struct guehdr {
 37         union {                                    34         union {
 38                 struct {                           35                 struct {
 39 #if defined(__LITTLE_ENDIAN_BITFIELD)              36 #if defined(__LITTLE_ENDIAN_BITFIELD)
 40                         __u8    hlen:5,            37                         __u8    hlen:5,
 41                                 control:1,         38                                 control:1,
 42                                 version:2;         39                                 version:2;
 43 #elif defined (__BIG_ENDIAN_BITFIELD)              40 #elif defined (__BIG_ENDIAN_BITFIELD)
 44                         __u8    version:2,         41                         __u8    version:2,
 45                                 control:1,         42                                 control:1,
 46                                 hlen:5;            43                                 hlen:5;
 47 #else                                              44 #else
 48 #error  "Please fix <asm/byteorder.h>"             45 #error  "Please fix <asm/byteorder.h>"
 49 #endif                                             46 #endif
 50                         __u8    proto_ctype;       47                         __u8    proto_ctype;
 51                         __be16  flags;             48                         __be16  flags;
 52                 };                                 49                 };
 53                 __be32  word;                      50                 __be32  word;
 54         };                                         51         };
 55 };                                                 52 };
 56                                                    53 
 57 /* Standard flags in GUE header */                 54 /* Standard flags in GUE header */
 58                                                    55 
 59 #define GUE_FLAG_PRIV   htons(1<<0)     /* Pri     56 #define GUE_FLAG_PRIV   htons(1<<0)     /* Private flags are in options */
 60 #define GUE_LEN_PRIV    4                          57 #define GUE_LEN_PRIV    4
 61                                                    58 
 62 #define GUE_FLAGS_ALL   (GUE_FLAG_PRIV)            59 #define GUE_FLAGS_ALL   (GUE_FLAG_PRIV)
 63                                                    60 
 64 /* Private flags in the private option extensi     61 /* Private flags in the private option extension */
 65                                                    62 
 66 #define GUE_PFLAG_REMCSUM       htonl(1U << 31     63 #define GUE_PFLAG_REMCSUM       htonl(1U << 31)
 67 #define GUE_PLEN_REMCSUM        4                  64 #define GUE_PLEN_REMCSUM        4
 68                                                    65 
 69 #define GUE_PFLAGS_ALL  (GUE_PFLAG_REMCSUM)        66 #define GUE_PFLAGS_ALL  (GUE_PFLAG_REMCSUM)
 70                                                    67 
 71 /* Functions to compute options length corresp     68 /* Functions to compute options length corresponding to flags.
 72  * If we ever have a lot of flags this can be      69  * If we ever have a lot of flags this can be potentially be
 73  * converted to a more optimized algorithm (ta     70  * converted to a more optimized algorithm (table lookup
 74  * for instance).                                  71  * for instance).
 75  */                                                72  */
 76 static inline size_t guehdr_flags_len(__be16 f     73 static inline size_t guehdr_flags_len(__be16 flags)
 77 {                                                  74 {
 78         return ((flags & GUE_FLAG_PRIV) ? GUE_     75         return ((flags & GUE_FLAG_PRIV) ? GUE_LEN_PRIV : 0);
 79 }                                                  76 }
 80                                                    77 
 81 static inline size_t guehdr_priv_flags_len(__b     78 static inline size_t guehdr_priv_flags_len(__be32 flags)
 82 {                                                  79 {
 83         return 0;                                  80         return 0;
 84 }                                                  81 }
 85                                                    82 
 86 /* Validate standard and private flags. Return     83 /* Validate standard and private flags. Returns non-zero (meaning invalid)
 87  * if there is an unknown standard or private      84  * if there is an unknown standard or private flags, or the options length for
 88  * the flags exceeds the options length specif     85  * the flags exceeds the options length specific in hlen of the GUE header.
 89  */                                                86  */
 90 static inline int validate_gue_flags(struct gu     87 static inline int validate_gue_flags(struct guehdr *guehdr, size_t optlen)
 91 {                                                  88 {
 92         __be16 flags = guehdr->flags;              89         __be16 flags = guehdr->flags;
 93         size_t len;                                90         size_t len;
 94                                                    91 
 95         if (flags & ~GUE_FLAGS_ALL)                92         if (flags & ~GUE_FLAGS_ALL)
 96                 return 1;                          93                 return 1;
 97                                                    94 
 98         len = guehdr_flags_len(flags);             95         len = guehdr_flags_len(flags);
 99         if (len > optlen)                          96         if (len > optlen)
100                 return 1;                          97                 return 1;
101                                                    98 
102         if (flags & GUE_FLAG_PRIV) {               99         if (flags & GUE_FLAG_PRIV) {
103                 /* Private flags are last four    100                 /* Private flags are last four bytes accounted in
104                  * guehdr_flags_len               101                  * guehdr_flags_len
105                  */                               102                  */
106                 __be32 pflags = *(__be32 *)((v    103                 __be32 pflags = *(__be32 *)((void *)&guehdr[1] +
107                                             le    104                                             len - GUE_LEN_PRIV);
108                                                   105 
109                 if (pflags & ~GUE_PFLAGS_ALL)     106                 if (pflags & ~GUE_PFLAGS_ALL)
110                         return 1;                 107                         return 1;
111                                                   108 
112                 len += guehdr_priv_flags_len(p    109                 len += guehdr_priv_flags_len(pflags);
113                 if (len > optlen)                 110                 if (len > optlen)
114                         return 1;                 111                         return 1;
115         }                                         112         }
116                                                   113 
117         return 0;                                 114         return 0;
118 }                                                 115 }
119                                                   116 
120 #endif                                            117 #endif
121                                                   118 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php