mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-22 16:59:03 +00:00
wireguard: support removing peers
Support removing peers by removing them from the component configuration. This commit also introduces the wg_reconfig run script that tests adding and removing single peers. Ref #4520
This commit is contained in:
committed by
Christian Helmuth
parent
560a166613
commit
86259b998e
@ -89,8 +89,11 @@ Peer_update_policy::Peer_update_policy(Allocator &alloc,
|
||||
|
||||
void Config_model::Peer_update_policy::destroy_element(Element &peer)
|
||||
{
|
||||
_callbacks.remove_peer(
|
||||
_listen_port, peer._endpoint_ip.addr, peer._endpoint_port);
|
||||
uint8_t public_key[WG_KEY_LEN];
|
||||
if (!key_from_base64(public_key, peer._public_key_b64.string())) {
|
||||
error("Invalid public key!");
|
||||
}
|
||||
_callbacks.remove_peer(public_key);
|
||||
|
||||
destroy(_alloc, &peer);
|
||||
}
|
||||
|
@ -241,6 +241,22 @@ void napi_enable(struct napi_struct * n)
|
||||
}
|
||||
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
void napi_disable(struct napi_struct * n)
|
||||
{
|
||||
lx_emul_trace(__func__);
|
||||
}
|
||||
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
void __netif_napi_del(struct napi_struct * napi)
|
||||
{
|
||||
lx_emul_trace(__func__);
|
||||
}
|
||||
|
||||
|
||||
#include <linux/mmzone.h>
|
||||
|
||||
struct mem_section ** mem_section = NULL;
|
||||
|
@ -347,11 +347,46 @@ _genode_wg_config_add_peer(genode_wg_u16_t listen_port,
|
||||
|
||||
|
||||
static void
|
||||
_genode_wg_config_rm_peer(genode_wg_u16_t listen_port,
|
||||
genode_wg_u8_t const endpoint_ip[4],
|
||||
genode_wg_u16_t endpoint_port)
|
||||
_genode_wg_config_rm_peer(genode_wg_u8_t const *const pub_key)
|
||||
{
|
||||
printk("%s not yet implemented\n", __func__);
|
||||
|
||||
struct genode_wg_nlattr_ifname ifname;
|
||||
struct genode_wg_nlattr_peers peers;
|
||||
struct nlattr *attrs[__WGDEVICE_A_LAST];
|
||||
struct genl_info info;
|
||||
struct genode_wg_nlattr_peer *peer = &peers.peer_0;
|
||||
|
||||
ifname.data[0] = '\0';
|
||||
ifname.header.nla_len = sizeof(ifname);
|
||||
|
||||
memset(&peers, 0, sizeof(peers));
|
||||
|
||||
peers.header.nla_type = WGDEVICE_A_PEERS | NLA_F_NESTED;
|
||||
peers.header.nla_len = sizeof(peers);
|
||||
|
||||
peer->header.nla_len = sizeof(*peer);
|
||||
peer->header.nla_type |= NLA_F_NESTED;
|
||||
|
||||
peer->public_key.header.nla_type = WGPEER_A_PUBLIC_KEY;
|
||||
peer->public_key.header.nla_len = sizeof(peer->public_key);
|
||||
memcpy(peer->public_key.data, pub_key, sizeof(peer->public_key.data));
|
||||
|
||||
peer->endpoint.header.nla_type = WGPEER_A_ENDPOINT;
|
||||
peer->endpoint.header.nla_len = sizeof(peer->endpoint);
|
||||
|
||||
peer->flags.header.nla_type = WGPEER_A_FLAGS;
|
||||
peer->flags.header.nla_len = sizeof(peer->flags);
|
||||
peer->flags.data = WGPEER_F_REMOVE_ME;
|
||||
|
||||
peer->allowedips.header.nla_len = sizeof(peer->allowedips);
|
||||
peer->allowedips.header.nla_type = WGPEER_A_ALLOWEDIPS | NLA_F_NESTED;
|
||||
|
||||
memset(attrs, 0, sizeof(attrs));
|
||||
attrs[WGDEVICE_A_IFNAME] = &ifname.header;
|
||||
attrs[WGDEVICE_A_PEERS] = &peers.header;
|
||||
|
||||
info.attrs = attrs;
|
||||
_genode_wg_set_device(&info);
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,9 +39,9 @@ typedef void (*genode_wg_config_add_peer_t) (
|
||||
genode_wg_u8_t const allowed_ip_prefix
|
||||
);
|
||||
|
||||
typedef void (*genode_wg_config_rm_peer_t)
|
||||
(genode_wg_u16_t listen_port, genode_wg_u8_t const endpoint_ip[4],
|
||||
genode_wg_u16_t endpoint_port);
|
||||
typedef void (*genode_wg_config_rm_peer_t) (
|
||||
genode_wg_u8_t const *const pub_key
|
||||
);
|
||||
|
||||
|
||||
struct genode_wg_config_callbacks
|
||||
|
@ -14,7 +14,19 @@
|
||||
/* app/wireguard includes */
|
||||
#include <lx_emul.h>
|
||||
|
||||
/* dde_linux/src/include/lx_emul */
|
||||
#include <lx_emul/random.h>
|
||||
|
||||
|
||||
#include <net/icmp.h>
|
||||
|
||||
void __icmp_send(struct sk_buff * skb_in,int type,int code,__be32 info,const struct ip_options * opt)
|
||||
{
|
||||
printk("Warning: sending ICMP not supported\n");
|
||||
kfree_skb(skb_in);
|
||||
}
|
||||
|
||||
|
||||
#include <linux/random.h>
|
||||
|
||||
void get_random_bytes(void * buf,int nbytes)
|
||||
|
@ -39,14 +39,6 @@ unsigned long __get_free_pages(gfp_t gfp_mask,unsigned int order)
|
||||
}
|
||||
|
||||
|
||||
#include <net/icmp.h>
|
||||
|
||||
void __icmp_send(struct sk_buff * skb_in,int type,int code,__be32 info,const struct ip_options * opt)
|
||||
{
|
||||
lx_emul_trace_and_stop(__func__);
|
||||
}
|
||||
|
||||
|
||||
#include <net/ipv6.h>
|
||||
|
||||
int __ipv6_addr_type(const struct in6_addr * addr)
|
||||
@ -71,14 +63,6 @@ struct irq_desc * __irq_resolve_mapping(struct irq_domain * domain,irq_hw_number
|
||||
}
|
||||
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
void __netif_napi_del(struct napi_struct * napi)
|
||||
{
|
||||
lx_emul_trace_and_stop(__func__);
|
||||
}
|
||||
|
||||
|
||||
#include <asm-generic/percpu.h>
|
||||
|
||||
unsigned long __per_cpu_offset[NR_CPUS] = {};
|
||||
@ -437,14 +421,6 @@ void migrate_enable(void)
|
||||
}
|
||||
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
void napi_disable(struct napi_struct * n)
|
||||
{
|
||||
lx_emul_trace_and_stop(__func__);
|
||||
}
|
||||
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
void netif_carrier_off(struct net_device * dev)
|
||||
|
@ -31,14 +31,6 @@ const char * __clk_get_name(const struct clk * clk)
|
||||
}
|
||||
|
||||
|
||||
#include <net/icmp.h>
|
||||
|
||||
void __icmp_send(struct sk_buff * skb_in,int type,int code,__be32 info,const struct ip_options * opt)
|
||||
{
|
||||
lx_emul_trace_and_stop(__func__);
|
||||
}
|
||||
|
||||
|
||||
#include <net/ipv6.h>
|
||||
|
||||
int __ipv6_addr_type(const struct in6_addr * addr)
|
||||
@ -63,14 +55,6 @@ struct irq_desc * __irq_resolve_mapping(struct irq_domain * domain,irq_hw_number
|
||||
}
|
||||
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
void __netif_napi_del(struct napi_struct * napi)
|
||||
{
|
||||
lx_emul_trace_and_stop(__func__);
|
||||
}
|
||||
|
||||
|
||||
#include <linux/mm.h>
|
||||
|
||||
void __put_page(struct page * page)
|
||||
@ -410,14 +394,6 @@ void kvfree(const void * addr)
|
||||
unsigned long lpj_fine;
|
||||
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
void napi_disable(struct napi_struct * n)
|
||||
{
|
||||
lx_emul_trace_and_stop(__func__);
|
||||
}
|
||||
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
void netif_carrier_off(struct net_device * dev)
|
||||
|
Reference in New Issue
Block a user