1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (c) 2015 Tom Herbert <tom@herbertland.com>
9 #include <linux/errno.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/socket.h>
14 #include <linux/skbuff.h>
15 #include <linux/types.h>
16 #include <net/checksum.h>
17 #include <net/genetlink.h>
19 #include <net/protocol.h>
20 #include <uapi/linux/ila.h>
31 struct ila_identifier
{
34 #if defined(__LITTLE_ENDIAN_BITFIELD)
38 #elif defined(__BIG_ENDIAN_BITFIELD)
43 #error "Adjust your <asm/byteorder.h> defines"
54 #define CSUM_NEUTRAL_FLAG htonl(0x10000000)
60 struct ila_locator loc
;
61 struct ila_identifier ident
;
66 static inline struct ila_addr
*ila_a2i(struct in6_addr
*addr
)
68 return (struct ila_addr
*)addr
;
72 struct ila_locator locator
;
73 struct ila_locator locator_match
;
79 static inline __wsum
compute_csum_diff8(const __be32
*from
, const __be32
*to
)
82 ~from
[0], ~from
[1], to
[0], to
[1],
85 return csum_partial(diff
, sizeof(diff
), 0);
88 static inline bool ila_csum_neutral_set(struct ila_identifier ident
)
90 return !!(ident
.csum_neutral
);
93 void ila_update_ipv6_locator(struct sk_buff
*skb
, struct ila_params
*p
,
94 bool set_csum_neutral
);
96 void ila_init_saved_csum(struct ila_params
*p
);
100 struct rhashtable rhash_table
;
101 spinlock_t
*locks
; /* Bucket locks for entry manipulation */
102 unsigned int locks_mask
;
103 bool hooks_registered
;
107 int ila_lwt_init(void);
108 void ila_lwt_fini(void);
110 int ila_xlat_init_net(struct net
*net
);
111 void ila_xlat_exit_net(struct net
*net
);
113 int ila_xlat_nl_cmd_add_mapping(struct sk_buff
*skb
, struct genl_info
*info
);
114 int ila_xlat_nl_cmd_del_mapping(struct sk_buff
*skb
, struct genl_info
*info
);
115 int ila_xlat_nl_cmd_get_mapping(struct sk_buff
*skb
, struct genl_info
*info
);
116 int ila_xlat_nl_cmd_flush(struct sk_buff
*skb
, struct genl_info
*info
);
117 int ila_xlat_nl_dump_start(struct netlink_callback
*cb
);
118 int ila_xlat_nl_dump_done(struct netlink_callback
*cb
);
119 int ila_xlat_nl_dump(struct sk_buff
*skb
, struct netlink_callback
*cb
);
121 extern unsigned int ila_net_id
;
123 extern struct genl_family ila_nl_family
;