Add basic support for VIMAGE to the LinuxKPI and ibcore.
Support is implemented by mapping Linux's "struct net" into FreeBSD's "struct vnet". Currently only vnet0 is supported by ibcore. MFC after: 1 week Sponsored by: Mellanox Technologies
This commit is contained in:
parent
6e2ab0aef5
commit
404027276b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=315404
@ -34,23 +34,25 @@
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
static inline struct net_device *
|
||||
ip_dev_find(struct net *net, uint32_t addr)
|
||||
ip_dev_find(struct vnet *vnet, uint32_t addr)
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
struct ifaddr *ifa;
|
||||
struct ifnet *ifp;
|
||||
|
||||
ifp = NULL;
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_addr.s_addr = addr;
|
||||
sin.sin_port = 0;
|
||||
sin.sin_len = sizeof(sin);
|
||||
sin.sin_family = AF_INET;
|
||||
CURVNET_SET_QUIET(vnet);
|
||||
ifa = ifa_ifwithaddr((struct sockaddr *)&sin);
|
||||
CURVNET_RESTORE();
|
||||
if (ifa) {
|
||||
ifp = ifa->ifa_ifp;
|
||||
if_ref(ifp);
|
||||
ifa_free(ifa);
|
||||
} else {
|
||||
ifp = NULL;
|
||||
}
|
||||
return (ifp);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright (c) 2010 Isilon Systems, Inc.
|
||||
* Copyright (c) 2010 iX Systems, Inc.
|
||||
* Copyright (c) 2010 Panasas, Inc.
|
||||
* Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
|
||||
* Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -40,25 +40,38 @@
|
||||
#include <net/if_var.h>
|
||||
#include <net/if_dl.h>
|
||||
|
||||
#include <linux/list.h>
|
||||
#include <linux/completion.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/net.h>
|
||||
#include <linux/notifier.h>
|
||||
|
||||
struct net {
|
||||
};
|
||||
|
||||
extern struct net init_net;
|
||||
#ifdef VIMAGE
|
||||
#define init_net *vnet0
|
||||
#else
|
||||
#define init_net *((struct vnet *)0)
|
||||
#endif
|
||||
|
||||
#define MAX_ADDR_LEN 20
|
||||
|
||||
#define net_device ifnet
|
||||
|
||||
#define dev_get_by_index(n, idx) ifnet_byindex_ref((idx))
|
||||
#define dev_hold(d) if_ref((d))
|
||||
#define dev_put(d) if_rele((d))
|
||||
#define dev_net(d) (&init_net)
|
||||
static inline struct ifnet *
|
||||
dev_get_by_index(struct vnet *vnet, int if_index)
|
||||
{
|
||||
struct ifnet *retval;
|
||||
|
||||
CURVNET_SET(vnet);
|
||||
retval = ifnet_byindex_ref(if_index);
|
||||
CURVNET_RESTORE();
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
#define dev_hold(d) if_ref(d)
|
||||
#define dev_put(d) if_rele(d)
|
||||
#define dev_net(d) ((d)->if_vnet)
|
||||
|
||||
#define net_eq(a,b) ((a) == (b))
|
||||
|
||||
|
@ -92,7 +92,6 @@ struct device linux_root_device;
|
||||
struct class linux_class_misc;
|
||||
struct list_head pci_drivers;
|
||||
struct list_head pci_devices;
|
||||
struct net init_net;
|
||||
spinlock_t pci_lock;
|
||||
|
||||
unsigned long linux_timer_hz_mask;
|
||||
|
@ -161,7 +161,9 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr,
|
||||
scope_id = sin6->sin6_scope_id;
|
||||
if (IN6_IS_SCOPE_LINKLOCAL(&sin6->sin6_addr))
|
||||
SCOPE_ID_CACHE(scope_id, sin6);
|
||||
CURVNET_SET_QUIET(&init_net);
|
||||
ifa = ifa_ifwithaddr(addr);
|
||||
CURVNET_RESTORE();
|
||||
sin6->sin6_port = port;
|
||||
if (IN6_IS_SCOPE_LINKLOCAL(&sin6->sin6_addr))
|
||||
SCOPE_ID_RESTORE(scope_id, sin6);
|
||||
@ -231,6 +233,9 @@ static int addr_resolve(struct sockaddr *src_in,
|
||||
int bcast;
|
||||
int is_gw = 0;
|
||||
int error = 0;
|
||||
|
||||
CURVNET_SET_QUIET(&init_net);
|
||||
|
||||
/*
|
||||
* Determine whether the address is unicast, multicast, or broadcast
|
||||
* and whether the source interface is valid.
|
||||
@ -271,7 +276,9 @@ static int addr_resolve(struct sockaddr *src_in,
|
||||
* up first and verify that it is a local
|
||||
* interface:
|
||||
*/
|
||||
CURVNET_SET_QUIET(&init_net);
|
||||
ifa = ifa_ifwithaddr(src_in);
|
||||
CURVNET_RESTORE();
|
||||
sin->sin_port = port;
|
||||
if (ifa == NULL) {
|
||||
error = ENETUNREACH;
|
||||
@ -312,7 +319,9 @@ static int addr_resolve(struct sockaddr *src_in,
|
||||
* up first and verify that it is a local
|
||||
* interface:
|
||||
*/
|
||||
CURVNET_SET_QUIET(&init_net);
|
||||
ifa = ifa_ifwithaddr(src_in);
|
||||
CURVNET_RESTORE();
|
||||
sin6->sin6_port = port;
|
||||
if (ifa == NULL) {
|
||||
error = ENETUNREACH;
|
||||
@ -426,6 +435,8 @@ static int addr_resolve(struct sockaddr *src_in,
|
||||
#endif
|
||||
if (error == EWOULDBLOCK)
|
||||
error = ENODATA;
|
||||
|
||||
CURVNET_RESTORE();
|
||||
return -error;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user