mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 04:34:11 +08:00
1713cb37bf
An FoU socket is currently bound to the wildcard-address. While this works fine, there are several use-cases where the use of the wildcard-address is not desirable. For example, I use FoU on some multi-homed servers and would like to use FoU on only one of the interfaces. This commit adds support for binding FoU sockets to a given source address/interface, as well as connecting the socket to a given destination address/port. udp_tunnel already provides the required infrastructure, so most of the code added is for exposing and setting the different attributes (local address, peer address, etc.). The lookups performed when we add, delete or get an FoU-socket has also been updated to compare all the attributes a user can set. Since the comparison now involves several elements, I have added a separate comparison-function instead of open-coding. In order to test the code and ensure that the new comparison code works correctly, I started by creating a wildcard socket bound to port 1234 on my machine. I then tried to create a non-wildcarded socket bound to the same port, as well as fetching and deleting the socket (including source address, peer address or interface index in the netlink request). Both the create, fetch and delete request failed. Deleting/fetching the socket was only successful when my netlink request attributes matched those used to create the socket. I then repeated the tests, but with a socket bound to a local ip address, a socket bound to a local address + interface, and a bound socket that was also «connected» to a peer. Add only worked when no socket with the matching source address/interface (or wildcard) existed, while fetch/delete was only successful when all attributes matched. In addition to testing that the new code work, I also checked that the current behavior is kept. If none of the new attributes are provided, then an FoU-socket is configured as before (i.e., wildcarded). If any of the new attributes are provided, the FoU-socket is configured as expected. v1->v2: * Fixed building with IPv6 disabled (kbuild). * Fixed a return type warning and make the ugly comparison function more readable (kbuild). * Describe more in detail what has been tested (thanks David Miller). * Make peer port required if peer address is specified. Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
49 lines
909 B
C
49 lines
909 B
C
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
|
/* fou.h - FOU Interface */
|
|
|
|
#ifndef _UAPI_LINUX_FOU_H
|
|
#define _UAPI_LINUX_FOU_H
|
|
|
|
/* NETLINK_GENERIC related info
|
|
*/
|
|
#define FOU_GENL_NAME "fou"
|
|
#define FOU_GENL_VERSION 0x1
|
|
|
|
enum {
|
|
FOU_ATTR_UNSPEC,
|
|
FOU_ATTR_PORT, /* u16 */
|
|
FOU_ATTR_AF, /* u8 */
|
|
FOU_ATTR_IPPROTO, /* u8 */
|
|
FOU_ATTR_TYPE, /* u8 */
|
|
FOU_ATTR_REMCSUM_NOPARTIAL, /* flag */
|
|
FOU_ATTR_LOCAL_V4, /* u32 */
|
|
FOU_ATTR_LOCAL_V6, /* in6_addr */
|
|
FOU_ATTR_PEER_V4, /* u32 */
|
|
FOU_ATTR_PEER_V6, /* in6_addr */
|
|
FOU_ATTR_PEER_PORT, /* u16 */
|
|
FOU_ATTR_IFINDEX, /* s32 */
|
|
|
|
__FOU_ATTR_MAX,
|
|
};
|
|
|
|
#define FOU_ATTR_MAX (__FOU_ATTR_MAX - 1)
|
|
|
|
enum {
|
|
FOU_CMD_UNSPEC,
|
|
FOU_CMD_ADD,
|
|
FOU_CMD_DEL,
|
|
FOU_CMD_GET,
|
|
|
|
__FOU_CMD_MAX,
|
|
};
|
|
|
|
enum {
|
|
FOU_ENCAP_UNSPEC,
|
|
FOU_ENCAP_DIRECT,
|
|
FOU_ENCAP_GUE,
|
|
};
|
|
|
|
#define FOU_CMD_MAX (__FOU_CMD_MAX - 1)
|
|
|
|
#endif /* _UAPI_LINUX_FOU_H */
|