hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/include/net/mpls.h
....@@ -1,14 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (c) 2014 Nicira, Inc.
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of version 2 of the GNU General Public
6
- * License as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful, but
9
- * WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
- * General Public License for more details.
124 */
135
146 #ifndef _NET_MPLS_H
....@@ -16,6 +8,7 @@
168
179 #include <linux/if_ether.h>
1810 #include <linux/netdevice.h>
11
+#include <linux/mpls.h>
1912
2013 #define MPLS_HLEN 4
2114
....@@ -33,4 +26,20 @@
3326 {
3427 return (struct mpls_shim_hdr *)skb_network_header(skb);
3528 }
29
+
30
+static inline struct mpls_shim_hdr mpls_entry_encode(u32 label,
31
+ unsigned int ttl,
32
+ unsigned int tc,
33
+ bool bos)
34
+{
35
+ struct mpls_shim_hdr result;
36
+
37
+ result.label_stack_entry =
38
+ cpu_to_be32((label << MPLS_LS_LABEL_SHIFT) |
39
+ (tc << MPLS_LS_TC_SHIFT) |
40
+ (bos ? (1 << MPLS_LS_S_SHIFT) : 0) |
41
+ (ttl << MPLS_LS_TTL_SHIFT));
42
+ return result;
43
+}
44
+
3645 #endif