diff mbox series

[OpenWrt-Devel] 回复: [PATCH] interface-ip: fix find locally addressable target for p2p

Message ID AM6PR03MB4821A0DBD99D2B7F7F49254DB50A0@AM6PR03MB4821.eurprd03.prod.outlook.com
State Superseded
Headers show
Series [OpenWrt-Devel] 回复: [PATCH] interface-ip: fix find locally addressable target for p2p | expand

Commit Message

Tan Xiaofan May 16, 2019, 3:09 p.m. UTC
Hi, I add some explanation to the patch

From 57007eef77f266e40640a2c76aabd56fd37553f7 Mon Sep 17 00:00:00 2001
From: xiaofan <xfan1024@live.com>
Date: Thu, 16 May 2019 21:12:47 +0800
Subject: [PATCH] interface-ip: fix find locally addressable target for p2p

In case of tunnel over PPP(such as gretap over l2tp): tunnel interface
use PPP's peer address as remote address, netifd script will call
proto_add_host_dependency function, then netifd will search which device
can reach to the remote address. Before the patch, netifd don't consider
the PPP interface can reach to the remote address, so netifd will select
default route to remote address, it will lead to remote address unreachable.

Signed-off-by: xiaofan <xfan1024@live.com>
---
 interface-ip.c | 3 +++
 1 file changed, 3 insertions(+)

--
2.17.1




>
> Hi,
>
> On Thu, May 16, 2019 at 4:01 PM Tan Xiaofan <xfan1024@live.com> wrote:
> >
> > From d0e1cb81b45ec825199d499cda9c8daef94e13a5 Mon Sep 17 00:00:00 2001
> > From: xiaofan <xfan1024@live.com>
> > Date: Thu, 16 May 2019 21:12:47 +0800
> > Subject: [PATCH] interface-ip: fix find locally addressable target for p2p
> The patch fails to explain why this change is required and what
> usecase/problem it fixes.
>
> Hans
> >
> > Signed-off-by: xiaofan <xfan1024@live.com>
> > ---
> >  interface-ip.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/interface-ip.c b/interface-ip.c
> > index 6900cd7..7ab8643 100644
> > --- a/interface-ip.c
> > +++ b/interface-ip.c
> > @@ -196,6 +196,10 @@ __find_ip_addr_target(struct interface_ip_settings *ip, union if_addr *a, bool v
> >    if (v6 != ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6))
> >     continue;
> >
> > +  if (!v6 && addr->point_to_point && a->in.s_addr == addr->point_to_point) {
> > +   return true;
> > +  }
> > +
> >    /* Handle offlink addresses correctly */
> >    unsigned int mask = addr->mask;
> >    if ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6 &&
> > --
> > 2.17.1
> >
> >
> > _______________________________________________
> > openwrt-devel mailing list
> > openwrt-devel@lists.openwrt.org
> > https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>

Comments

Hans Dedecker May 16, 2019, 4:40 p.m. UTC | #1
Hi

On Thu, May 16, 2019 at 5:09 PM Tan Xiaofan <xfan1024@live.com> wrote:
>
> Hi, I add some explanation to the patch
>
> From 57007eef77f266e40640a2c76aabd56fd37553f7 Mon Sep 17 00:00:00 2001
> From: xiaofan <xfan1024@live.com>
> Date: Thu, 16 May 2019 21:12:47 +0800
> Subject: [PATCH] interface-ip: fix find locally addressable target for p2p
>
> In case of tunnel over PPP(such as gretap over l2tp): tunnel interface
> use PPP's peer address as remote address, netifd script will call
> proto_add_host_dependency function, then netifd will search which device
> can reach to the remote address. Before the patch, netifd don't consider
> the PPP interface can reach to the remote address, so netifd will select
> default route to remote address, it will lead to remote address unreachable.
The patch fails to apply with the updated commit description; please
resend after you've created the patch via git format-patch with the
updated git commit description

Hans
>
> Signed-off-by: xiaofan <xfan1024@live.com>
> ---
>  interface-ip.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/interface-ip.c b/interface-ip.c
> index 6900cd7..8d5587c 100644
> --- a/interface-ip.c
> +++ b/interface-ip.c
> @@ -196,6 +196,9 @@ __find_ip_addr_target(struct interface_ip_settings *ip, union if_addr *a, bool v
>    if (v6 != ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6))
>     continue;
>
> +  if (!v6 && addr->point_to_point && a->in.s_addr == addr->point_to_point)
> +   return true;
> +
>    /* Handle offlink addresses correctly */
>    unsigned int mask = addr->mask;
>    if ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6 &&
> --
> 2.17.1
>
>
>
>
> >
> > Hi,
> >
> > On Thu, May 16, 2019 at 4:01 PM Tan Xiaofan <xfan1024@live.com> wrote:
> > >
> > > From d0e1cb81b45ec825199d499cda9c8daef94e13a5 Mon Sep 17 00:00:00 2001
> > > From: xiaofan <xfan1024@live.com>
> > > Date: Thu, 16 May 2019 21:12:47 +0800
> > > Subject: [PATCH] interface-ip: fix find locally addressable target for p2p
> > The patch fails to explain why this change is required and what
> > usecase/problem it fixes.
> >
> > Hans
> > >
> > > Signed-off-by: xiaofan <xfan1024@live.com>
> > > ---
> > >  interface-ip.c | 4 ++++
> > >  1 file changed, 4 insertions(+)
> > >
> > > diff --git a/interface-ip.c b/interface-ip.c
> > > index 6900cd7..7ab8643 100644
> > > --- a/interface-ip.c
> > > +++ b/interface-ip.c
> > > @@ -196,6 +196,10 @@ __find_ip_addr_target(struct interface_ip_settings *ip, union if_addr *a, bool v
> > >    if (v6 != ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6))
> > >     continue;
> > >
> > > +  if (!v6 && addr->point_to_point && a->in.s_addr == addr->point_to_point) {
> > > +   return true;
> > > +  }
> > > +
> > >    /* Handle offlink addresses correctly */
> > >    unsigned int mask = addr->mask;
> > >    if ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6 &&
> > > --
> > > 2.17.1
> > >
> > >
> > > _______________________________________________
> > > openwrt-devel mailing list
> > > openwrt-devel@lists.openwrt.org
> > > https://lists.openwrt.org/mailman/listinfo/openwrt-devel
> >
Tan Xiaofan May 16, 2019, 6 p.m. UTC | #2
Hi, the email replace TAB with SPACE, so apply failed.
So, I put the patch file in my server

	http://167.88.124.64/0001-interface-ip-fix-find-locally-addressable-target-for.patch

>  
> Hi
> 
> On Thu, May 16, 2019 at 5:09 PM Tan Xiaofan <xfan1024@live.com> wrote:
> >
> > Hi, I add some explanation to the patch
> >
> > From 57007eef77f266e40640a2c76aabd56fd37553f7 Mon Sep 17 00:00:00 2001
> > From: xiaofan <xfan1024@live.com>
> > Date: Thu, 16 May 2019 21:12:47 +0800
> > Subject: [PATCH] interface-ip: fix find locally addressable target for p2p
> >
> > In case of tunnel over PPP(such as gretap over l2tp): tunnel interface
> > use PPP's peer address as remote address, netifd script will call
> > proto_add_host_dependency function, then netifd will search which device
> > can reach to the remote address. Before the patch, netifd don't consider
> > the PPP interface can reach to the remote address, so netifd will select
> > default route to remote address, it will lead to remote address unreachable.
> The patch fails to apply with the updated commit description; please
> resend after you've created the patch via git format-patch with the
> updated git commit description
> 
> Hans
> >
> > Signed-off-by: xiaofan <xfan1024@live.com>
> > ---
> >  interface-ip.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/interface-ip.c b/interface-ip.c
> > index 6900cd7..8d5587c 100644
> > --- a/interface-ip.c
> > +++ b/interface-ip.c
> > @@ -196,6 +196,9 @@ __find_ip_addr_target(struct interface_ip_settings *ip, union if_addr *a, bool v
> >	if (v6 != ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6))
> >	 continue;
> >
> > +  if (!v6 && addr->point_to_point && a->in.s_addr == addr->point_to_point)
> > +   return true;
> > +
> >	/* Handle offlink addresses correctly */
> >	unsigned int mask = addr->mask;
> >	if ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6 &&
> > --
> > 2.17.1
> >
> >
> >
> >
Hans Dedecker May 17, 2019, 4:27 p.m. UTC | #3
Hi,

On Thu, May 16, 2019 at 8:00 PM Tan Xiaofan <xfan1024@live.com> wrote:
>
> Hi, the email replace TAB with SPACE, so apply failed.
> So, I put the patch file in my server
>
>         http://167.88.124.64/0001-interface-ip-fix-find-locally-addressable-target-for.patch
Can you share the network config which requires this patch ?

Hans
>
> >
> > Hi
> >
> > On Thu, May 16, 2019 at 5:09 PM Tan Xiaofan <xfan1024@live.com> wrote:
> > >
> > > Hi, I add some explanation to the patch
> > >
> > > From 57007eef77f266e40640a2c76aabd56fd37553f7 Mon Sep 17 00:00:00 2001
> > > From: xiaofan <xfan1024@live.com>
> > > Date: Thu, 16 May 2019 21:12:47 +0800
> > > Subject: [PATCH] interface-ip: fix find locally addressable target for p2p
> > >
> > > In case of tunnel over PPP(such as gretap over l2tp): tunnel interface
> > > use PPP's peer address as remote address, netifd script will call
> > > proto_add_host_dependency function, then netifd will search which device
> > > can reach to the remote address. Before the patch, netifd don't consider
> > > the PPP interface can reach to the remote address, so netifd will select
> > > default route to remote address, it will lead to remote address unreachable.
> > The patch fails to apply with the updated commit description; please
> > resend after you've created the patch via git format-patch with the
> > updated git commit description
> >
> > Hans
> > >
> > > Signed-off-by: xiaofan <xfan1024@live.com>
> > > ---
> > >  interface-ip.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > >
> > > diff --git a/interface-ip.c b/interface-ip.c
> > > index 6900cd7..8d5587c 100644
> > > --- a/interface-ip.c
> > > +++ b/interface-ip.c
> > > @@ -196,6 +196,9 @@ __find_ip_addr_target(struct interface_ip_settings *ip, union if_addr *a, bool v
> > >     if (v6 != ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6))
> > >      continue;
> > >
> > > +  if (!v6 && addr->point_to_point && a->in.s_addr == addr->point_to_point)
> > > +   return true;
> > > +
> > >     /* Handle offlink addresses correctly */
> > >     unsigned int mask = addr->mask;
> > >     if ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6 &&
> > > --
> > > 2.17.1
> > >
> > >
> > >
> > >
Tan Xiaofan May 17, 2019, 5:27 p.m. UTC | #4
Hi

> Can you share the network config which requires this patch ?
> 
> Hans

config interface 'wan'
	option ifname 'eth0'
	option proto 'dhcp'

config interface 'iptun'
	option proto 'l2tp'
	option defaultroute '0'
	option server '192.168.100.1'   # l2tp server

config interface 'veth'
	option proto 'gretap'
	option ipaddr '10.255.255.100'  # iptun ipaddr
	option peeraddr '10.255.255.1'  # iptun peeraddr
	# option tunlink 'iptun'
Hans Dedecker May 17, 2019, 6:46 p.m. UTC | #5
On Fri, May 17, 2019 at 7:27 PM Tan Xiaofan <xfan1024@live.com> wrote:
>
> Hi
>
> > Can you share the network config which requires this patch ?
> >
> > Hans
>
> config interface 'wan'
>         option ifname 'eth0'
>         option proto 'dhcp'
>
> config interface 'iptun'
>         option proto 'l2tp'
>         option defaultroute '0'
>         option server '192.168.100.1'   # l2tp server
>
> config interface 'veth'
>         option proto 'gretap'
>         option ipaddr '10.255.255.100'  # iptun ipaddr
>         option peeraddr '10.255.255.1'  # iptun peeraddr
>         # option tunlink 'iptun'
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Hans Dedecker May 17, 2019, 6:48 p.m. UTC | #6
Hi,

On Fri, May 17, 2019 at 7:27 PM Tan Xiaofan <xfan1024@live.com> wrote:
>
> Hi
>
> > Can you share the network config which requires this patch ?
> >
> > Hans
>
> config interface 'wan'
>         option ifname 'eth0'
>         option proto 'dhcp'
>
> config interface 'iptun'
>         option proto 'l2tp'
>         option defaultroute '0'
>         option server '192.168.100.1'   # l2tp server
>
> config interface 'veth'
>         option proto 'gretap'
>         option ipaddr '10.255.255.100'  # iptun ipaddr
>         option peeraddr '10.255.255.1'  # iptun peeraddr
>         # option tunlink 'iptun'
Thx for sharing the network config.
I've slightly reworked the patch
(https://git.openwrt.org/?p=project/netifd.git;a=commit;h=22e8e589fd6ab5d19dc1d3c9d1bcf2bfabf1fafb);
can you give it a try ?

Hans

> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Tan Xiaofan May 18, 2019, 1:44 a.m. UTC | #7
Hi, I tested the patch, it's work

> Thx for sharing the network config.
> I've slightly reworked the patch
> (https://git.openwrt.org/?p=project/netifd.git;a=commit;h=22e8e589fd6ab5d19dc1d3c9d1bcf2bfabf1fafb);
> can you give it a try ?

> Hans
diff mbox series

Patch

diff --git a/interface-ip.c b/interface-ip.c
index 6900cd7..8d5587c 100644
--- a/interface-ip.c
+++ b/interface-ip.c
@@ -196,6 +196,9 @@  __find_ip_addr_target(struct interface_ip_settings *ip, union if_addr *a, bool v
   if (v6 != ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6))
    continue;

+  if (!v6 && addr->point_to_point && a->in.s_addr == addr->point_to_point)
+   return true;
+
   /* Handle offlink addresses correctly */
   unsigned int mask = addr->mask;
   if ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6 &&