mt7628 wan插拔IP不更新问题
环境:
Kernel 5.4
驱动:esw_rt3050
原因:
以太网驱动监测到网线插拔时,没有成功发送信号到udhcpc进程,以释放ip+得新获取ip
Patch:
Index: linux-5.4.237/drivers/net/ethernet/ralink/esw_rt3050.c
===================================================================
--- linux-5.4.237.orig/drivers/net/ethernet/ralink/esw_rt3050.c
+++ linux-5.4.237/drivers/net/ethernet/ralink/esw_rt3050.c
@@ -458,8 +458,45 @@ static void esw_set_gsc(struct rt305x_es
static int esw_apply_config(struct switch_dev *dev);
+struct work_struct kill_sig_wq;
+
+void kill_sig_workq(struct work_struct *work)
+{
+ dev_info(NULL, "kill_sig_workq\n");
+ struct file *fp;
+ char pid[8];
+ struct task_struct *p = NULL;
+ //read udhcpc pid from file, and send signal USR2,USR1 to get a new IP
+ fp = filp_open("/var/run/udhcpc-eth0.2.pid", O_RDONLY, 0);
+ if (IS_ERR(fp)){
+ fp = filp_open("/var/run/udhcpc-eth0.1.pid", O_RDONLY, 0);
+ if (IS_ERR(fp)){
+ return;
+ }
+ }
+
+
+ // if (fp->f_op && fp->f_op->read) {
+ //if (fp->f_op->read(fp, pid, 8, &fp->f_pos) > 0) {
+ //kernel 5.4
+ if(kernel_read(fp, pid, 8, &fp->f_pos)){
+ p = pid_task(find_get_pid(simple_strtoul(pid, NULL, 10)), PIDTYPE_PID);
+ if (NULL != p) {
+ send_sig(SIGUSR2, p, 0);
+ send_sig(SIGUSR1, p, 0);
+ }
+ }
+ // }
+
+ filp_close(fp, NULL);
+
+}
+
+
+
static void esw_hw_init(struct rt305x_esw *esw)
{
+ INIT_WORK(&kill_sig_wq, kill_sig_workq);
int i;
u8 port_disable = 0;
u8 port_map = RT305X_ESW_PMAP_LLLLLL;
@@ -755,6 +792,8 @@ int rt3050_esw_has_carrier(struct fe_pri
dev_info(esw->dev, "port %d link %s\n", i, link & BIT(i) ? "up" : "down");
priv->link[i] = link & BIT(i);
}
+ schedule_work(&kill_sig_wq);
+
return !!link && cpuport;
}