[][Add API for deleting or adding interface to whnat_interface]
[Description]
Add API for deleting or adding interface to whnat_interface.
When creating an interface after initialization, since the interface is not in whnat_interface,
HNAT BIND info will be incorrect (this happens when there are 2 PPE)
[Usage]
- Command
- echo $0 $1 > /sys/kernel/debug/hnat/whnat_interface
- Parameters
- $0: interface_name STR
- $1: disable/enable OCT
[Release-log]
N/A
Change-Id: Ie5481e2ea46c36f216c63193e96614239c8226b9
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/5729194
diff --git a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_debugfs.c b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_debugfs.c
index a5403a8..69f1c21 100644
--- a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_debugfs.c
+++ b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_debugfs.c
@@ -1036,10 +1036,52 @@
return single_open(file, hnat_whnat_show, file->private_data);
}
+static ssize_t hnat_whnat_write(struct file *file, const char __user *buf,
+ size_t length, loff_t *offset)
+{
+ char line[64] = {0};
+ struct net_device *dev;
+ int enable;
+ char name[32];
+ size_t size;
+
+ if (length >= sizeof(line))
+ return -EINVAL;
+
+ if (copy_from_user(line, buf, length))
+ return -EFAULT;
+
+ if (sscanf(line, "%s %d", name, &enable) != 2)
+ return -EFAULT;
+
+ line[length] = '\0';
+
+ dev = dev_get_by_name(&init_net, name);
+
+ if (dev) {
+ if (enable) {
+ mtk_ppe_dev_register_hook(dev);
+ pr_info("register wifi extern if = %s\n", dev->name);
+ } else {
+ mtk_ppe_dev_unregister_hook(dev);
+ pr_info("unregister wifi extern if = %s\n", dev->name);
+ }
+ } else {
+ pr_info("no such device!\n");
+ }
+
+ size = strlen(line);
+ *offset += size;
+
+ return length;
+}
+
+
static const struct file_operations hnat_whnat_fops = {
.open = hnat_whnat_open,
.read = seq_read,
.llseek = seq_lseek,
+ .write = hnat_whnat_write,
.release = single_release,
};