| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#ifndef _NET_OVPN_DCO_LINUX_COMPAT_H_ |
| 11 |
#define _NET_OVPN_DCO_LINUX_COMPAT_H_ |
| 12 |
|
| 13 |
#include <linux/kconfig.h> |
| 14 |
#include <linux/version.h> |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
#ifndef RHEL_RELEASE_CODE |
| 30 |
#define RHEL_RELEASE_CODE 0 |
| 31 |
#endif |
| 32 |
#ifndef RHEL_RELEASE_VERSION |
| 33 |
#define RHEL_RELEASE_VERSION(m, n) 1 |
| 34 |
#endif |
| 35 |
|
| 36 |
#ifndef SUSE_PRODUCT_CODE |
| 37 |
#define SUSE_PRODUCT_CODE 0 |
| 38 |
#endif |
| 39 |
#ifndef SUSE_PRODUCT |
| 40 |
#define SUSE_PRODUCT(pr, v, pl, aux) 1 |
| 41 |
#endif |
| 42 |
|
| 43 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(7, 1, 5) |
| 44 |
|
| 45 |
#include <net/udp_tunnel.h> |
| 46 |
|
| 47 |
static inline void ovpn_setup_udp_tunnel_sock(struct net *net, struct sock *sk, |
| 48 |
struct udp_tunnel_sock_cfg *cfg) |
| 49 |
{ |
| 50 |
setup_udp_tunnel_sock(net, sk->sk_socket, cfg); |
| 51 |
} |
| 52 |
|
| 53 |
#define setup_udp_tunnel_sock ovpn_setup_udp_tunnel_sock |
| 54 |
|
| 55 |
#endif |
| 56 |
|
| 57 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(7, 1, 0) |
| 58 |
|
| 59 |
#include <net/ipv6_stubs.h> |
| 60 |
|
| 61 |
static inline struct dst_entry * |
| 62 |
ovpn_ip6_dst_lookup_flow(struct net *net, const struct sock *sk, |
| 63 |
struct flowi6 *fl6, const struct in6_addr *final_dst) |
| 64 |
{ |
| 65 |
return ipv6_stub->ipv6_dst_lookup_flow(net, sk, fl6, final_dst); |
| 66 |
} |
| 67 |
#define ip6_dst_lookup_flow ovpn_ip6_dst_lookup_flow |
| 68 |
|
| 69 |
#endif |
| 70 |
|
| 71 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 17, 0) |
| 72 |
|
| 73 |
#include <net/udp_tunnel.h> |
| 74 |
|
| 75 |
static inline void ovpn_udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, |
| 76 |
struct sk_buff *skb, __be32 src, |
| 77 |
__be32 dst, __u8 tos, __u8 ttl, |
| 78 |
__be16 df, __be16 src_port, |
| 79 |
__be16 dst_port, bool xnet, |
| 80 |
bool nocheck, u16 ipcb_flags) |
| 81 |
{ |
| 82 |
udp_tunnel_xmit_skb(rt, sk, skb, src, dst, tos, ttl, df, src_port, |
| 83 |
dst_port, xnet, nocheck); |
| 84 |
} |
| 85 |
#define udp_tunnel_xmit_skb ovpn_udp_tunnel_xmit_skb |
| 86 |
|
| 87 |
static inline void ovpn_udp_tunnel6_xmit_skb(struct dst_entry *dst, |
| 88 |
struct sock *sk, |
| 89 |
struct sk_buff *skb, |
| 90 |
struct net_device *dev, |
| 91 |
struct in6_addr *saddr, |
| 92 |
struct in6_addr *daddr, |
| 93 |
__u8 prio, __u8 ttl, __be32 label, |
| 94 |
__be16 src_port, __be16 dst_port, |
| 95 |
bool nocheck, u16 ip6cb_flags) |
| 96 |
{ |
| 97 |
udp_tunnel6_xmit_skb(dst, sk, skb, dev, saddr, daddr, prio, ttl, label, |
| 98 |
src_port, dst_port, nocheck); |
| 99 |
} |
| 100 |
#define udp_tunnel6_xmit_skb ovpn_udp_tunnel6_xmit_skb |
| 101 |
|
| 102 |
#endif |
| 103 |
|
| 104 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) |
| 105 |
|
| 106 |
#ifndef UDP_ENCAP_OVPNINUDP |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
#define UDP_ENCAP_OVPNINUDP 100 |
| 111 |
#endif |
| 112 |
|
| 113 |
|
| 114 |
enum ovpn_ifla_attrs { |
| 115 |
IFLA_OVPN_UNSPEC = 0, |
| 116 |
IFLA_OVPN_MODE, |
| 117 |
|
| 118 |
__IFLA_OVPN_AFTER_LAST, |
| 119 |
IFLA_OVPN_MAX = __IFLA_OVPN_AFTER_LAST - 1, |
| 120 |
}; |
| 121 |
|
| 122 |
enum ovpn_mode { |
| 123 |
__OVPN_MODE_FIRST = 0, |
| 124 |
OVPN_MODE_P2P = __OVPN_MODE_FIRST, |
| 125 |
OVPN_MODE_MP, |
| 126 |
|
| 127 |
__OVPN_MODE_AFTER_LAST, |
| 128 |
}; |
| 129 |
|
| 130 |
#if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(9, 8) |
| 131 |
|
| 132 |
#define timer_container_of from_timer |
| 133 |
|
| 134 |
#endif |
| 135 |
|
| 136 |
#else |
| 137 |
|
| 138 |
#define __OVPN_MODE_FIRST 0 |
| 139 |
#define __OVPN_MODE_AFTER_LAST (OVPN_MODE_MP + 1) |
| 140 |
|
| 141 |
#endif |
| 142 |
|
| 143 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0) |
| 144 |
|
| 145 |
#include <linux/timer.h> |
| 146 |
#define timer_delete del_timer |
| 147 |
#define timer_delete_sync del_timer_sync |
| 148 |
|
| 149 |
#endif |
| 150 |
|
| 151 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0) |
| 152 |
|
| 153 |
#ifndef NLA_POLICY_MAX_LEN |
| 154 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) |
| 155 |
#define NLA_POLICY_MAX_LEN(_len) { .type = NLA_BINARY, .len = _len } |
| 156 |
#else |
| 157 |
#define NLA_POLICY_MAX_LEN(_len) NLA_POLICY_MAX(NLA_BINARY, _len) |
| 158 |
#endif |
| 159 |
#endif |
| 160 |
|
| 161 |
#endif |
| 162 |
|
| 163 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0) && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(9, 6) |
| 164 |
|
| 165 |
#include <linux/netdev_features.h> |
| 166 |
#undef NETIF_F_SG |
| 167 |
#define NETIF_F_SG (__NETIF_F(SG) | NETIF_F_LLTX) |
| 168 |
|
| 169 |
#define lltx needs_free_netdev |
| 170 |
|
| 171 |
#endif |
| 172 |
|
| 173 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0) && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(9, 3) |
| 174 |
|
| 175 |
#define genl_split_ops genl_ops |
| 176 |
|
| 177 |
#endif |
| 178 |
|
| 179 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0) && \ |
| 180 |
SUSE_PRODUCT_CODE < SUSE_PRODUCT(1, 15, 5, 0) && \ |
| 181 |
RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(8, 10) |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
#define netif_napi_add_tx_weight netif_tx_napi_add |
| 188 |
|
| 189 |
#endif |
| 190 |
|
| 191 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0) && \ |
| 192 |
SUSE_PRODUCT_CODE < SUSE_PRODUCT(1, 15, 5, 0) && \ |
| 193 |
RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(9, 6) |
| 194 |
|
| 195 |
#define sock_is_readable stream_memory_read |
| 196 |
|
| 197 |
#endif |
| 198 |
|
| 199 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(8, 0) |
| 200 |
|
| 201 |
#define dev_get_tstats64 ip_tunnel_get_stats64 |
| 202 |
|
| 203 |
#include <linux/netdevice.h> |
| 204 |
|
| 205 |
static inline void dev_sw_netstats_tx_add(struct net_device *dev, |
| 206 |
unsigned int packets, |
| 207 |
unsigned int len) |
| 208 |
{ |
| 209 |
struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); |
| 210 |
|
| 211 |
u64_stats_update_begin(&tstats->syncp); |
| 212 |
tstats->tx_bytes += len; |
| 213 |
tstats->tx_packets += packets; |
| 214 |
u64_stats_update_end(&tstats->syncp); |
| 215 |
} |
| 216 |
|
| 217 |
#endif |
| 218 |
|
| 219 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(8, 0) |
| 220 |
|
| 221 |
#define genl_small_ops genl_ops |
| 222 |
#define small_ops ops |
| 223 |
#define n_small_ops n_ops |
| 224 |
|
| 225 |
#endif |
| 226 |
|
| 227 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(8, 0) |
| 228 |
|
| 229 |
#include <linux/netdevice.h> |
| 230 |
|
| 231 |
static inline void dev_sw_netstats_rx_add(struct net_device *dev, unsigned int len) |
| 232 |
{ |
| 233 |
struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); |
| 234 |
|
| 235 |
u64_stats_update_begin(&tstats->syncp); |
| 236 |
tstats->rx_bytes += len; |
| 237 |
tstats->rx_packets++; |
| 238 |
u64_stats_update_end(&tstats->syncp); |
| 239 |
} |
| 240 |
|
| 241 |
#endif |
| 242 |
|
| 243 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) |
| 244 |
|
| 245 |
|
| 246 |
#define skb_list_walk_safe(first, skb, next_skb) \ |
| 247 |
for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb); \ |
| 248 |
(skb) = (next_skb), (next_skb) = (skb) ? (skb)->next : NULL) |
| 249 |
|
| 250 |
#endif |
| 251 |
|
| 252 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0) |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
#undef rcu_replace_pointer |
| 265 |
#define rcu_replace_pointer(rcu_ptr, ptr, c) \ |
| 266 |
({ \ |
| 267 |
typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ |
| 268 |
rcu_assign_pointer((rcu_ptr), (ptr)); \ |
| 269 |
__tmp; \ |
| 270 |
}) |
| 271 |
|
| 272 |
#endif |
| 273 |
|
| 274 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) && SUSE_PRODUCT_CODE < SUSE_PRODUCT(1, 15, 3, 0) |
| 275 |
|
| 276 |
|
| 277 |
#undef nf_reset_ct |
| 278 |
#define nf_reset_ct nf_reset |
| 279 |
|
| 280 |
#endif |
| 281 |
|
| 282 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0) |
| 283 |
|
| 284 |
|
| 285 |
#define rt_gw4 rt_gateway |
| 286 |
|
| 287 |
#endif |
| 288 |
|
| 289 |
#endif |