18c2ecf20Sopenharmony_ci#ifndef __NET_NSH_H 28c2ecf20Sopenharmony_ci#define __NET_NSH_H 1 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#include <linux/skbuff.h> 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci/* 78c2ecf20Sopenharmony_ci * Network Service Header: 88c2ecf20Sopenharmony_ci * 0 1 2 3 98c2ecf20Sopenharmony_ci * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 108c2ecf20Sopenharmony_ci * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 118c2ecf20Sopenharmony_ci * |Ver|O|U| TTL | Length |U|U|U|U|MD Type| Next Protocol | 128c2ecf20Sopenharmony_ci * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 138c2ecf20Sopenharmony_ci * | Service Path Identifier (SPI) | Service Index | 148c2ecf20Sopenharmony_ci * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 158c2ecf20Sopenharmony_ci * | | 168c2ecf20Sopenharmony_ci * ~ Mandatory/Optional Context Headers ~ 178c2ecf20Sopenharmony_ci * | | 188c2ecf20Sopenharmony_ci * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * Version: The version field is used to ensure backward compatibility 218c2ecf20Sopenharmony_ci * going forward with future NSH specification updates. It MUST be set 228c2ecf20Sopenharmony_ci * to 0x0 by the sender, in this first revision of NSH. Given the 238c2ecf20Sopenharmony_ci * widespread implementation of existing hardware that uses the first 248c2ecf20Sopenharmony_ci * nibble after an MPLS label stack for ECMP decision processing, this 258c2ecf20Sopenharmony_ci * document reserves version 01b and this value MUST NOT be used in 268c2ecf20Sopenharmony_ci * future versions of the protocol. Please see [RFC7325] for further 278c2ecf20Sopenharmony_ci * discussion of MPLS-related forwarding requirements. 288c2ecf20Sopenharmony_ci * 298c2ecf20Sopenharmony_ci * O bit: Setting this bit indicates an Operations, Administration, and 308c2ecf20Sopenharmony_ci * Maintenance (OAM) packet. The actual format and processing of SFC 318c2ecf20Sopenharmony_ci * OAM packets is outside the scope of this specification (see for 328c2ecf20Sopenharmony_ci * example [I-D.ietf-sfc-oam-framework] for one approach). 338c2ecf20Sopenharmony_ci * 348c2ecf20Sopenharmony_ci * The O bit MUST be set for OAM packets and MUST NOT be set for non-OAM 358c2ecf20Sopenharmony_ci * packets. The O bit MUST NOT be modified along the SFP. 368c2ecf20Sopenharmony_ci * 378c2ecf20Sopenharmony_ci * SF/SFF/SFC Proxy/Classifier implementations that do not support SFC 388c2ecf20Sopenharmony_ci * OAM procedures SHOULD discard packets with O bit set, but MAY support 398c2ecf20Sopenharmony_ci * a configurable parameter to enable forwarding received SFC OAM 408c2ecf20Sopenharmony_ci * packets unmodified to the next element in the chain. Forwarding OAM 418c2ecf20Sopenharmony_ci * packets unmodified by SFC elements that do not support SFC OAM 428c2ecf20Sopenharmony_ci * procedures may be acceptable for a subset of OAM functions, but can 438c2ecf20Sopenharmony_ci * result in unexpected outcomes for others, thus it is recommended to 448c2ecf20Sopenharmony_ci * analyze the impact of forwarding an OAM packet for all OAM functions 458c2ecf20Sopenharmony_ci * prior to enabling this behavior. The configurable parameter MUST be 468c2ecf20Sopenharmony_ci * disabled by default. 478c2ecf20Sopenharmony_ci * 488c2ecf20Sopenharmony_ci * TTL: Indicates the maximum SFF hops for an SFP. This field is used 498c2ecf20Sopenharmony_ci * for service plane loop detection. The initial TTL value SHOULD be 508c2ecf20Sopenharmony_ci * configurable via the control plane; the configured initial value can 518c2ecf20Sopenharmony_ci * be specific to one or more SFPs. If no initial value is explicitly 528c2ecf20Sopenharmony_ci * provided, the default initial TTL value of 63 MUST be used. Each SFF 538c2ecf20Sopenharmony_ci * involved in forwarding an NSH packet MUST decrement the TTL value by 548c2ecf20Sopenharmony_ci * 1 prior to NSH forwarding lookup. Decrementing by 1 from an incoming 558c2ecf20Sopenharmony_ci * value of 0 shall result in a TTL value of 63. The packet MUST NOT be 568c2ecf20Sopenharmony_ci * forwarded if TTL is, after decrement, 0. 578c2ecf20Sopenharmony_ci * 588c2ecf20Sopenharmony_ci * All other flag fields, marked U, are unassigned and available for 598c2ecf20Sopenharmony_ci * future use, see Section 11.2.1. Unassigned bits MUST be set to zero 608c2ecf20Sopenharmony_ci * upon origination, and MUST be ignored and preserved unmodified by 618c2ecf20Sopenharmony_ci * other NSH supporting elements. Elements which do not understand the 628c2ecf20Sopenharmony_ci * meaning of any of these bits MUST NOT modify their actions based on 638c2ecf20Sopenharmony_ci * those unknown bits. 648c2ecf20Sopenharmony_ci * 658c2ecf20Sopenharmony_ci * Length: The total length, in 4-byte words, of NSH including the Base 668c2ecf20Sopenharmony_ci * Header, the Service Path Header, the Fixed Length Context Header or 678c2ecf20Sopenharmony_ci * Variable Length Context Header(s). The length MUST be 0x6 for MD 688c2ecf20Sopenharmony_ci * Type equal to 0x1, and MUST be 0x2 or greater for MD Type equal to 698c2ecf20Sopenharmony_ci * 0x2. The length of the NSH header MUST be an integer multiple of 4 708c2ecf20Sopenharmony_ci * bytes, thus variable length metadata is always padded out to a 718c2ecf20Sopenharmony_ci * multiple of 4 bytes. 728c2ecf20Sopenharmony_ci * 738c2ecf20Sopenharmony_ci * MD Type: Indicates the format of NSH beyond the mandatory Base Header 748c2ecf20Sopenharmony_ci * and the Service Path Header. MD Type defines the format of the 758c2ecf20Sopenharmony_ci * metadata being carried. 768c2ecf20Sopenharmony_ci * 778c2ecf20Sopenharmony_ci * 0x0 - This is a reserved value. Implementations SHOULD silently 788c2ecf20Sopenharmony_ci * discard packets with MD Type 0x0. 798c2ecf20Sopenharmony_ci * 808c2ecf20Sopenharmony_ci * 0x1 - This indicates that the format of the header includes a fixed 818c2ecf20Sopenharmony_ci * length Context Header (see Figure 4 below). 828c2ecf20Sopenharmony_ci * 838c2ecf20Sopenharmony_ci * 0x2 - This does not mandate any headers beyond the Base Header and 848c2ecf20Sopenharmony_ci * Service Path Header, but may contain optional variable length Context 858c2ecf20Sopenharmony_ci * Header(s). The semantics of the variable length Context Header(s) 868c2ecf20Sopenharmony_ci * are not defined in this document. The format of the optional 878c2ecf20Sopenharmony_ci * variable length Context Headers is provided in Section 2.5.1. 888c2ecf20Sopenharmony_ci * 898c2ecf20Sopenharmony_ci * 0xF - This value is reserved for experimentation and testing, as per 908c2ecf20Sopenharmony_ci * [RFC3692]. Implementations not explicitly configured to be part of 918c2ecf20Sopenharmony_ci * an experiment SHOULD silently discard packets with MD Type 0xF. 928c2ecf20Sopenharmony_ci * 938c2ecf20Sopenharmony_ci * Next Protocol: indicates the protocol type of the encapsulated data. 948c2ecf20Sopenharmony_ci * NSH does not alter the inner payload, and the semantics on the inner 958c2ecf20Sopenharmony_ci * protocol remain unchanged due to NSH service function chaining. 968c2ecf20Sopenharmony_ci * Please see the IANA Considerations section below, Section 11.2.5. 978c2ecf20Sopenharmony_ci * 988c2ecf20Sopenharmony_ci * This document defines the following Next Protocol values: 998c2ecf20Sopenharmony_ci * 1008c2ecf20Sopenharmony_ci * 0x1: IPv4 1018c2ecf20Sopenharmony_ci * 0x2: IPv6 1028c2ecf20Sopenharmony_ci * 0x3: Ethernet 1038c2ecf20Sopenharmony_ci * 0x4: NSH 1048c2ecf20Sopenharmony_ci * 0x5: MPLS 1058c2ecf20Sopenharmony_ci * 0xFE: Experiment 1 1068c2ecf20Sopenharmony_ci * 0xFF: Experiment 2 1078c2ecf20Sopenharmony_ci * 1088c2ecf20Sopenharmony_ci * Packets with Next Protocol values not supported SHOULD be silently 1098c2ecf20Sopenharmony_ci * dropped by default, although an implementation MAY provide a 1108c2ecf20Sopenharmony_ci * configuration parameter to forward them. Additionally, an 1118c2ecf20Sopenharmony_ci * implementation not explicitly configured for a specific experiment 1128c2ecf20Sopenharmony_ci * [RFC3692] SHOULD silently drop packets with Next Protocol values 0xFE 1138c2ecf20Sopenharmony_ci * and 0xFF. 1148c2ecf20Sopenharmony_ci * 1158c2ecf20Sopenharmony_ci * Service Path Identifier (SPI): Identifies a service path. 1168c2ecf20Sopenharmony_ci * Participating nodes MUST use this identifier for Service Function 1178c2ecf20Sopenharmony_ci * Path selection. The initial classifier MUST set the appropriate SPI 1188c2ecf20Sopenharmony_ci * for a given classification result. 1198c2ecf20Sopenharmony_ci * 1208c2ecf20Sopenharmony_ci * Service Index (SI): Provides location within the SFP. The initial 1218c2ecf20Sopenharmony_ci * classifier for a given SFP SHOULD set the SI to 255, however the 1228c2ecf20Sopenharmony_ci * control plane MAY configure the initial value of SI as appropriate 1238c2ecf20Sopenharmony_ci * (i.e., taking into account the length of the service function path). 1248c2ecf20Sopenharmony_ci * The Service Index MUST be decremented by a value of 1 by Service 1258c2ecf20Sopenharmony_ci * Functions or by SFC Proxy nodes after performing required services 1268c2ecf20Sopenharmony_ci * and the new decremented SI value MUST be used in the egress packet's 1278c2ecf20Sopenharmony_ci * NSH. The initial Classifier MUST send the packet to the first SFF in 1288c2ecf20Sopenharmony_ci * the identified SFP for forwarding along an SFP. If re-classification 1298c2ecf20Sopenharmony_ci * occurs, and that re-classification results in a new SPI, the 1308c2ecf20Sopenharmony_ci * (re)classifier is, in effect, the initial classifier for the 1318c2ecf20Sopenharmony_ci * resultant SPI. 1328c2ecf20Sopenharmony_ci * 1338c2ecf20Sopenharmony_ci * The SI is used in conjunction the with Service Path Identifier for 1348c2ecf20Sopenharmony_ci * Service Function Path Selection and for determining the next SFF/SF 1358c2ecf20Sopenharmony_ci * in the path. The SI is also valuable when troubleshooting or 1368c2ecf20Sopenharmony_ci * reporting service paths. Additionally, while the TTL field is the 1378c2ecf20Sopenharmony_ci * main mechanism for service plane loop detection, the SI can also be 1388c2ecf20Sopenharmony_ci * used for detecting service plane loops. 1398c2ecf20Sopenharmony_ci * 1408c2ecf20Sopenharmony_ci * When the Base Header specifies MD Type = 0x1, a Fixed Length Context 1418c2ecf20Sopenharmony_ci * Header (16-bytes) MUST be present immediately following the Service 1428c2ecf20Sopenharmony_ci * Path Header. The value of a Fixed Length Context 1438c2ecf20Sopenharmony_ci * Header that carries no metadata MUST be set to zero. 1448c2ecf20Sopenharmony_ci * 1458c2ecf20Sopenharmony_ci * When the base header specifies MD Type = 0x2, zero or more Variable 1468c2ecf20Sopenharmony_ci * Length Context Headers MAY be added, immediately following the 1478c2ecf20Sopenharmony_ci * Service Path Header (see Figure 5). Therefore, Length = 0x2, 1488c2ecf20Sopenharmony_ci * indicates that only the Base Header followed by the Service Path 1498c2ecf20Sopenharmony_ci * Header are present. The optional Variable Length Context Headers 1508c2ecf20Sopenharmony_ci * MUST be of an integer number of 4-bytes. The base header Length 1518c2ecf20Sopenharmony_ci * field MUST be used to determine the offset to locate the original 1528c2ecf20Sopenharmony_ci * packet or frame for SFC nodes that require access to that 1538c2ecf20Sopenharmony_ci * information. 1548c2ecf20Sopenharmony_ci * 1558c2ecf20Sopenharmony_ci * The format of the optional variable length Context Headers 1568c2ecf20Sopenharmony_ci * 1578c2ecf20Sopenharmony_ci * 0 1 2 3 1588c2ecf20Sopenharmony_ci * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1598c2ecf20Sopenharmony_ci * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1608c2ecf20Sopenharmony_ci * | Metadata Class | Type |U| Length | 1618c2ecf20Sopenharmony_ci * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1628c2ecf20Sopenharmony_ci * | Variable Metadata | 1638c2ecf20Sopenharmony_ci * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1648c2ecf20Sopenharmony_ci * 1658c2ecf20Sopenharmony_ci * Metadata Class (MD Class): Defines the scope of the 'Type' field to 1668c2ecf20Sopenharmony_ci * provide a hierarchical namespace. The IANA Considerations 1678c2ecf20Sopenharmony_ci * Section 11.2.4 defines how the MD Class values can be allocated to 1688c2ecf20Sopenharmony_ci * standards bodies, vendors, and others. 1698c2ecf20Sopenharmony_ci * 1708c2ecf20Sopenharmony_ci * Type: Indicates the explicit type of metadata being carried. The 1718c2ecf20Sopenharmony_ci * definition of the Type is the responsibility of the MD Class owner. 1728c2ecf20Sopenharmony_ci * 1738c2ecf20Sopenharmony_ci * Unassigned bit: One unassigned bit is available for future use. This 1748c2ecf20Sopenharmony_ci * bit MUST NOT be set, and MUST be ignored on receipt. 1758c2ecf20Sopenharmony_ci * 1768c2ecf20Sopenharmony_ci * Length: Indicates the length of the variable metadata, in bytes. In 1778c2ecf20Sopenharmony_ci * case the metadata length is not an integer number of 4-byte words, 1788c2ecf20Sopenharmony_ci * the sender MUST add pad bytes immediately following the last metadata 1798c2ecf20Sopenharmony_ci * byte to extend the metadata to an integer number of 4-byte words. 1808c2ecf20Sopenharmony_ci * The receiver MUST round up the length field to the nearest 4-byte 1818c2ecf20Sopenharmony_ci * word boundary, to locate and process the next field in the packet. 1828c2ecf20Sopenharmony_ci * The receiver MUST access only those bytes in the metadata indicated 1838c2ecf20Sopenharmony_ci * by the length field (i.e., actual number of bytes) and MUST ignore 1848c2ecf20Sopenharmony_ci * the remaining bytes up to the nearest 4-byte word boundary. The 1858c2ecf20Sopenharmony_ci * Length may be 0 or greater. 1868c2ecf20Sopenharmony_ci * 1878c2ecf20Sopenharmony_ci * A value of 0 denotes a Context Header without a Variable Metadata 1888c2ecf20Sopenharmony_ci * field. 1898c2ecf20Sopenharmony_ci * 1908c2ecf20Sopenharmony_ci * [0] https://datatracker.ietf.org/doc/draft-ietf-sfc-nsh/ 1918c2ecf20Sopenharmony_ci */ 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci/** 1948c2ecf20Sopenharmony_ci * struct nsh_md1_ctx - Keeps track of NSH context data 1958c2ecf20Sopenharmony_ci * @nshc<1-4>: NSH Contexts. 1968c2ecf20Sopenharmony_ci */ 1978c2ecf20Sopenharmony_cistruct nsh_md1_ctx { 1988c2ecf20Sopenharmony_ci __be32 context[4]; 1998c2ecf20Sopenharmony_ci}; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_cistruct nsh_md2_tlv { 2028c2ecf20Sopenharmony_ci __be16 md_class; 2038c2ecf20Sopenharmony_ci u8 type; 2048c2ecf20Sopenharmony_ci u8 length; 2058c2ecf20Sopenharmony_ci u8 md_value[]; 2068c2ecf20Sopenharmony_ci}; 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_cistruct nshhdr { 2098c2ecf20Sopenharmony_ci __be16 ver_flags_ttl_len; 2108c2ecf20Sopenharmony_ci u8 mdtype; 2118c2ecf20Sopenharmony_ci u8 np; 2128c2ecf20Sopenharmony_ci __be32 path_hdr; 2138c2ecf20Sopenharmony_ci union { 2148c2ecf20Sopenharmony_ci struct nsh_md1_ctx md1; 2158c2ecf20Sopenharmony_ci struct nsh_md2_tlv md2; 2168c2ecf20Sopenharmony_ci }; 2178c2ecf20Sopenharmony_ci}; 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci/* Masking NSH header fields. */ 2208c2ecf20Sopenharmony_ci#define NSH_VER_MASK 0xc000 2218c2ecf20Sopenharmony_ci#define NSH_VER_SHIFT 14 2228c2ecf20Sopenharmony_ci#define NSH_FLAGS_MASK 0x3000 2238c2ecf20Sopenharmony_ci#define NSH_FLAGS_SHIFT 12 2248c2ecf20Sopenharmony_ci#define NSH_TTL_MASK 0x0fc0 2258c2ecf20Sopenharmony_ci#define NSH_TTL_SHIFT 6 2268c2ecf20Sopenharmony_ci#define NSH_LEN_MASK 0x003f 2278c2ecf20Sopenharmony_ci#define NSH_LEN_SHIFT 0 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci#define NSH_MDTYPE_MASK 0x0f 2308c2ecf20Sopenharmony_ci#define NSH_MDTYPE_SHIFT 0 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci#define NSH_SPI_MASK 0xffffff00 2338c2ecf20Sopenharmony_ci#define NSH_SPI_SHIFT 8 2348c2ecf20Sopenharmony_ci#define NSH_SI_MASK 0x000000ff 2358c2ecf20Sopenharmony_ci#define NSH_SI_SHIFT 0 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci/* MD Type Registry. */ 2388c2ecf20Sopenharmony_ci#define NSH_M_TYPE1 0x01 2398c2ecf20Sopenharmony_ci#define NSH_M_TYPE2 0x02 2408c2ecf20Sopenharmony_ci#define NSH_M_EXP1 0xFE 2418c2ecf20Sopenharmony_ci#define NSH_M_EXP2 0xFF 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci/* NSH Base Header Length */ 2448c2ecf20Sopenharmony_ci#define NSH_BASE_HDR_LEN 8 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_ci/* NSH MD Type 1 header Length. */ 2478c2ecf20Sopenharmony_ci#define NSH_M_TYPE1_LEN 24 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci/* NSH header maximum Length. */ 2508c2ecf20Sopenharmony_ci#define NSH_HDR_MAX_LEN 256 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci/* NSH context headers maximum Length. */ 2538c2ecf20Sopenharmony_ci#define NSH_CTX_HDRS_MAX_LEN 248 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_cistatic inline struct nshhdr *nsh_hdr(struct sk_buff *skb) 2568c2ecf20Sopenharmony_ci{ 2578c2ecf20Sopenharmony_ci return (struct nshhdr *)skb_network_header(skb); 2588c2ecf20Sopenharmony_ci} 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_cistatic inline u16 nsh_hdr_len(const struct nshhdr *nsh) 2618c2ecf20Sopenharmony_ci{ 2628c2ecf20Sopenharmony_ci return ((ntohs(nsh->ver_flags_ttl_len) & NSH_LEN_MASK) 2638c2ecf20Sopenharmony_ci >> NSH_LEN_SHIFT) << 2; 2648c2ecf20Sopenharmony_ci} 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_cistatic inline u8 nsh_get_ver(const struct nshhdr *nsh) 2678c2ecf20Sopenharmony_ci{ 2688c2ecf20Sopenharmony_ci return (ntohs(nsh->ver_flags_ttl_len) & NSH_VER_MASK) 2698c2ecf20Sopenharmony_ci >> NSH_VER_SHIFT; 2708c2ecf20Sopenharmony_ci} 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_cistatic inline u8 nsh_get_flags(const struct nshhdr *nsh) 2738c2ecf20Sopenharmony_ci{ 2748c2ecf20Sopenharmony_ci return (ntohs(nsh->ver_flags_ttl_len) & NSH_FLAGS_MASK) 2758c2ecf20Sopenharmony_ci >> NSH_FLAGS_SHIFT; 2768c2ecf20Sopenharmony_ci} 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_cistatic inline u8 nsh_get_ttl(const struct nshhdr *nsh) 2798c2ecf20Sopenharmony_ci{ 2808c2ecf20Sopenharmony_ci return (ntohs(nsh->ver_flags_ttl_len) & NSH_TTL_MASK) 2818c2ecf20Sopenharmony_ci >> NSH_TTL_SHIFT; 2828c2ecf20Sopenharmony_ci} 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_cistatic inline void __nsh_set_xflag(struct nshhdr *nsh, u16 xflag, u16 xmask) 2858c2ecf20Sopenharmony_ci{ 2868c2ecf20Sopenharmony_ci nsh->ver_flags_ttl_len 2878c2ecf20Sopenharmony_ci = (nsh->ver_flags_ttl_len & ~htons(xmask)) | htons(xflag); 2888c2ecf20Sopenharmony_ci} 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_cistatic inline void nsh_set_flags_and_ttl(struct nshhdr *nsh, u8 flags, u8 ttl) 2918c2ecf20Sopenharmony_ci{ 2928c2ecf20Sopenharmony_ci __nsh_set_xflag(nsh, ((flags << NSH_FLAGS_SHIFT) & NSH_FLAGS_MASK) | 2938c2ecf20Sopenharmony_ci ((ttl << NSH_TTL_SHIFT) & NSH_TTL_MASK), 2948c2ecf20Sopenharmony_ci NSH_FLAGS_MASK | NSH_TTL_MASK); 2958c2ecf20Sopenharmony_ci} 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_cistatic inline void nsh_set_flags_ttl_len(struct nshhdr *nsh, u8 flags, 2988c2ecf20Sopenharmony_ci u8 ttl, u8 len) 2998c2ecf20Sopenharmony_ci{ 3008c2ecf20Sopenharmony_ci len = len >> 2; 3018c2ecf20Sopenharmony_ci __nsh_set_xflag(nsh, ((flags << NSH_FLAGS_SHIFT) & NSH_FLAGS_MASK) | 3028c2ecf20Sopenharmony_ci ((ttl << NSH_TTL_SHIFT) & NSH_TTL_MASK) | 3038c2ecf20Sopenharmony_ci ((len << NSH_LEN_SHIFT) & NSH_LEN_MASK), 3048c2ecf20Sopenharmony_ci NSH_FLAGS_MASK | NSH_TTL_MASK | NSH_LEN_MASK); 3058c2ecf20Sopenharmony_ci} 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ciint nsh_push(struct sk_buff *skb, const struct nshhdr *pushed_nh); 3088c2ecf20Sopenharmony_ciint nsh_pop(struct sk_buff *skb); 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci#endif /* __NET_NSH_H */ 311