mirror of
https://github.com/Slava-Shchipunov/awg-openwrt.git
synced 2026-03-14 01:13:09 +00:00
sync up with the upstream
This commit is contained in:
@@ -44,22 +44,24 @@ diff --color -urN -x uapi -x compat -x crypto -x .idea -x tests -x Kbuild -x Kco
|
||||
pr_debug("%s: Interface created\n", dev->name);
|
||||
return ret;
|
||||
|
||||
@@ -475,4 +480,79 @@
|
||||
@@ -475,4 +480,118 @@
|
||||
unregister_random_vmfork_notifier(&vm_notifier);
|
||||
unregister_pm_notifier(&pm_notifier);
|
||||
rcu_barrier();
|
||||
+}
|
||||
+
|
||||
+void wg_device_handle_post_config(struct net_device *dev, struct amnezia_config *asc)
|
||||
+int wg_device_handle_post_config(struct net_device *dev, struct amnezia_config *asc)
|
||||
+{
|
||||
+ struct wg_device *wg = netdev_priv(dev);
|
||||
+ bool a_sec_on = false;
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ if (!asc->advanced_security_enabled)
|
||||
+ return;
|
||||
+ goto out;
|
||||
+
|
||||
+ if (asc->junk_packet_count < 0) {
|
||||
+ // TODO error
|
||||
+ net_dbg_ratelimited("%s: JunkPacketCount should be non negative\n", dev->name);
|
||||
+ ret = -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ wg->advanced_security_config.junk_packet_count = asc->junk_packet_count;
|
||||
@@ -77,9 +79,15 @@ diff --color -urN -x uapi -x compat -x crypto -x .idea -x tests -x Kbuild -x Kco
|
||||
+ wg->advanced_security_config.junk_packet_min_size = 0;
|
||||
+ wg->advanced_security_config.junk_packet_max_size = 1;
|
||||
+
|
||||
+ // TODO error
|
||||
+ net_dbg_ratelimited("%s: JunkPacketMaxSize: %d; should be smaller than maxSegmentSize: %d\n",
|
||||
+ dev->name, asc->junk_packet_max_size,
|
||||
+ MESSAGE_MAX_SIZE);
|
||||
+ ret = -EINVAL;
|
||||
+ } else if (asc->junk_packet_max_size < asc->junk_packet_min_size) {
|
||||
+ // TODO error
|
||||
+ net_dbg_ratelimited("%s: maxSize: %d; should be greater than minSize: %d\n",
|
||||
+ dev->name, asc->junk_packet_max_size,
|
||||
+ asc->junk_packet_min_size);
|
||||
+ ret = -EINVAL;
|
||||
+ } else
|
||||
+ wg->advanced_security_config.junk_packet_max_size = asc->junk_packet_max_size;
|
||||
+
|
||||
@@ -87,7 +95,10 @@ diff --color -urN -x uapi -x compat -x crypto -x .idea -x tests -x Kbuild -x Kco
|
||||
+ a_sec_on = true;
|
||||
+
|
||||
+ if (asc->init_packet_junk_size + MESSAGE_INITIATION_SIZE >= MESSAGE_MAX_SIZE) {
|
||||
+ // TODO error
|
||||
+ net_dbg_ratelimited("%s: init header size (%d) + junkSize (%d) should be smaller than maxSegmentSize: %d\n",
|
||||
+ dev->name, MESSAGE_INITIATION_SIZE,
|
||||
+ asc->init_packet_junk_size, MESSAGE_MAX_SIZE);
|
||||
+ ret = -EINVAL;
|
||||
+ } else
|
||||
+ wg->advanced_security_config.init_packet_junk_size = asc->init_packet_junk_size;
|
||||
+
|
||||
@@ -95,7 +106,10 @@ diff --color -urN -x uapi -x compat -x crypto -x .idea -x tests -x Kbuild -x Kco
|
||||
+ a_sec_on = true;
|
||||
+
|
||||
+ if (asc->response_packet_junk_size + MESSAGE_RESPONSE_SIZE >= MESSAGE_MAX_SIZE) {
|
||||
+ // TODO error
|
||||
+ net_dbg_ratelimited("%s: response header size (%d) + junkSize (%d) should be smaller than maxSegmentSize: %d\n",
|
||||
+ dev->name, MESSAGE_RESPONSE_SIZE,
|
||||
+ asc->response_packet_junk_size, MESSAGE_MAX_SIZE);
|
||||
+ ret = -EINVAL;
|
||||
+ } else
|
||||
+ wg->advanced_security_config.response_packet_junk_size = asc->response_packet_junk_size;
|
||||
+
|
||||
@@ -122,7 +136,32 @@ diff --color -urN -x uapi -x compat -x crypto -x .idea -x tests -x Kbuild -x Kco
|
||||
+ wg->advanced_security_config.transport_packet_magic_header = asc->transport_packet_magic_header;
|
||||
+ }
|
||||
+
|
||||
+ if (asc->init_packet_magic_header == asc->response_packet_magic_header ||
|
||||
+ asc->init_packet_magic_header == asc->cookie_packet_magic_header ||
|
||||
+ asc->init_packet_magic_header == asc->transport_packet_magic_header ||
|
||||
+ asc->response_packet_magic_header == asc->cookie_packet_magic_header ||
|
||||
+ asc->response_packet_magic_header == asc->transport_packet_magic_header ||
|
||||
+ asc->cookie_packet_magic_header == asc->transport_packet_magic_header) {
|
||||
+ net_dbg_ratelimited("%s: magic headers should differ; got: init:%d; recv:%d; unde:%d; tran:%d\n",
|
||||
+ dev->name,
|
||||
+ asc->init_packet_magic_header,
|
||||
+ asc->response_packet_magic_header,
|
||||
+ asc->cookie_packet_magic_header,
|
||||
+ asc->transport_packet_magic_header);
|
||||
+ ret = -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ if (MESSAGE_INITIATION_SIZE + asc->init_packet_junk_size == MESSAGE_RESPONSE_SIZE + asc->response_packet_junk_size) {
|
||||
+ net_dbg_ratelimited("%s: new init size:%d; and new response size:%d; should differ\n",
|
||||
+ dev->name,
|
||||
+ MESSAGE_INITIATION_SIZE + asc->init_packet_junk_size,
|
||||
+ MESSAGE_RESPONSE_SIZE + asc->response_packet_junk_size);
|
||||
+ ret = -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ wg->advanced_security_config.advanced_security_enabled = a_sec_on;
|
||||
+out:
|
||||
+ return ret;
|
||||
}
|
||||
diff --color -urN -x uapi -x compat -x crypto -x .idea -x tests -x Kbuild -x Kconfig -x Makefile -x dkms.conf ../../linux-source-6.2.0/drivers/net/wireguard/device.h ./device.h
|
||||
--- ../../linux-source-6.2.0/drivers/net/wireguard/device.h 2023-11-10 18:10:29
|
||||
@@ -159,7 +198,7 @@ diff --color -urN -x uapi -x compat -x crypto -x .idea -x tests -x Kbuild -x Kco
|
||||
|
||||
int wg_device_init(void);
|
||||
void wg_device_uninit(void);
|
||||
+void wg_device_handle_post_config(struct net_device *dev, struct amnezia_config *asc);
|
||||
+int wg_device_handle_post_config(struct net_device *dev, struct amnezia_config *asc);
|
||||
|
||||
#endif /* _WG_DEVICE_H */
|
||||
diff --color -urN -x uapi -x compat -x crypto -x .idea -x tests -x Kbuild -x Kconfig -x Makefile -x dkms.conf ../../linux-source-6.2.0/drivers/net/wireguard/main.c ./main.c
|
||||
@@ -334,11 +373,13 @@ diff --color -urN -x uapi -x compat -x crypto -x .idea -x tests -x Kbuild -x Kco
|
||||
if (flags & WGDEVICE_F_REPLACE_PEERS)
|
||||
wg_peer_remove_all(wg);
|
||||
|
||||
@@ -597,10 +670,12 @@
|
||||
@@ -597,10 +670,14 @@
|
||||
ret = 0;
|
||||
|
||||
out:
|
||||
+ wg_device_handle_post_config(wg->dev, asc);
|
||||
+ if (!ret)
|
||||
+ ret = wg_device_handle_post_config(wg->dev, asc);
|
||||
+
|
||||
mutex_unlock(&wg->device_update_lock);
|
||||
rtnl_unlock();
|
||||
dev_put(wg->dev);
|
||||
|
||||
Reference in New Issue
Block a user