* Re: [PATCH net-next 2/3] tcp: allow segment with FIN in tcp_try_coalesce()
From: Eric Dumazet @ 2014-09-15 10:57 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David S. Miller, netdev, Yuchung Cheng, Neal Cardwell
In-Reply-To: <1410749780-30613-3-git-send-email-edumazet@google.com>
On Sun, 2014-09-14 at 19:56 -0700, Eric Dumazet wrote:
> There is nothing special with allowing a segment with FIN to be aggregated,
> if we take care to add tcp flags.
>
> Signed-of-by: Eric Dumazet <edumazet@google.com>
> ---
> net/ipv4/tcp_input.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index 8f639a4face9..228bf0c5ff19 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -4143,9 +4143,6 @@ static bool tcp_try_coalesce(struct sock *sk,
>
> *fragstolen = false;
>
> - if (tcp_hdr(from)->fin)
> - return false;
> -
> /* Its possible this segment overlaps with prior segment in queue */
> if (TCP_SKB_CB(from)->seq != TCP_SKB_CB(to)->end_seq)
> return false;
> @@ -4158,6 +4155,7 @@ static bool tcp_try_coalesce(struct sock *sk,
> NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPRCVCOALESCE);
> TCP_SKB_CB(to)->end_seq = TCP_SKB_CB(from)->end_seq;
> TCP_SKB_CB(to)->ack_seq = TCP_SKB_CB(from)->ack_seq;
> + TCP_SKB_CB(to)->tcp_flags |= TCP_SKB_CB(from)->tcp_flags;
> return true;
> }
>
This patch needs to be refined.
skb_try_coalesce() should not do an unconditional
BUG_ON(skb_copy_bits(from, 0, skb_put(to, len), len));
And do it only if len is non 0
I will send a v2
^ permalink raw reply
* Re: [PATCH firmware] rtl_nic: add firmware for RTL8168H and RTL8107E
From: Ivan Vecera @ 2014-09-15 10:45 UTC (permalink / raw)
To: Hayes Wang, dwmw2, ben; +Cc: netdev, linux-kernel, hau
In-Reply-To: <1394712342-15778-41-Taiwan-albertk@realtek.com>
Hayes,
the firmware files should be sent to linux-firmware@kernel.org
Ivan
On 12.9.2014 08:54, Hayes Wang wrote:
> File: rtl_nic/rtl8168h-1.fw
> Version: 0.0.1
>
> File: rtl_nic/rtl8168h-2.fw
> Version: 0.0.1
>
> File: rtl_nic/rtl8107e-1.fw
> Version: 0.0.1
>
> File: rtl_nic/rtl8107e-2.fw
> Version: 0.0.1
> Signed-off-by: Hayes Wang <hayeswang@realtek.com>
> ---
> WHENCE | 12 ++++++++++++
> rtl_nic/rtl8107e-1.fw | Bin 0 -> 2496 bytes
> rtl_nic/rtl8107e-2.fw | Bin 0 -> 2464 bytes
> rtl_nic/rtl8168h-1.fw | Bin 0 -> 2496 bytes
> rtl_nic/rtl8168h-2.fw | Bin 0 -> 2464 bytes
> 5 files changed, 12 insertions(+)
> create mode 100644 rtl_nic/rtl8107e-1.fw
> create mode 100644 rtl_nic/rtl8107e-2.fw
> create mode 100644 rtl_nic/rtl8168h-1.fw
> create mode 100644 rtl_nic/rtl8168h-2.fw
>
> diff --git a/WHENCE b/WHENCE
> index 26cabf4..3ffc68e 100644
> --- a/WHENCE
> +++ b/WHENCE
> @@ -2149,6 +2149,18 @@ Version: 0.0.1
> File: rtl_nic/rtl8168g-3.fw
> Version: 0.0.1
>
> +File: rtl_nic/rtl8168h-1.fw
> +Version: 0.0.1
> +
> +File: rtl_nic/rtl8168h-2.fw
> +Version: 0.0.1
> +
> +File: rtl_nic/rtl8107e-1.fw
> +Version: 0.0.1
> +
> +File: rtl_nic/rtl8107e-2.fw
> +Version: 0.0.1
> +
> Licence:
> * Copyright © 2011-2013, Realtek Semiconductor Corporation
> *
> diff --git a/rtl_nic/rtl8107e-1.fw b/rtl_nic/rtl8107e-1.fw
> new file mode 100644
> index 0000000000000000000000000000000000000000..5ac3d62bcd6adb9a28bc84dcccbccd99a0dab290
> GIT binary patch
> literal 2496
> zcmY+`aY$8J9tZH#8`lw6?5({q$7vb~2?^JE&%|{l<k3V(NQ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BS{v7H_4
> zq@4~r>7tw6^st9s`simb``FI`4iXvQ5QjO!QI0Xl5XU*eNltN^Gn{3Z5k@)3c`k5~
> zOI+p(SGmR**SWzs6HIcGDQ<C_J4|zzd)(&%51HW+kI6C198Y-4GoJH;m%QRNZ+Oc)
> z-ZTI0;=4l3kF(wvl8M6jK`2}JPsk4Zap4^z>9hEqh>PveyTpPEU0EBS4T<4S4=98`
> zq`xTqELO#3F?6J2&DgTIB&6a(UxhrBNX3$2=k%r2yy{d;{?<q;F8PPP=~V2^rDAre
> z_78lYicMwu2jy?nfmEESO2zVD=gL=?n=?=SNKL5A)S&*`xP`To)?T=d5Pn(zm-|{C
> e=Km8aLRdcW|LZpHfA{?J;<@BRc5z(z-SJ;Ub$cHG
>
> literal 0
> HcmV?d00001
>
> diff --git a/rtl_nic/rtl8107e-2.fw b/rtl_nic/rtl8107e-2.fw
> new file mode 100644
> index 0000000000000000000000000000000000000000..949ca670fa31242940caa9f2222c0e268274ae0c
> GIT binary patch
> literal 2464
> zcmYk;aY$8J9tZH#8^>`RF~{DR>$HtD5)!UGO&nJu-nb@ixDgT(5$QUPE3Jr#L`1|H
> zCnBN=iHL{@35kd{A|fPOainn~A|fIpA|4_U5p6_7MA&|GnxXsNhu`<yd(S!d-Sfvg
> zA%rk6*jrbX`sVw;RJW%pQ<YVvslTqQs$N-D<J#QO!9Nlqd>dL@YFE`(H?%jl{=IE&
> zYkU7c2fyoSZ|eJguzl^?wUys>|EsjBrhZjbebqPNr_r*xz6(M~PcHl_hLA%pdE`?-
> zAxVnjM<HaQ`*JcNF3cq2=b5ayD3cw($mGPuncVoNOkVsllOI3%Rlh$M#_6Au@#p5E
> znE0hQhX0ntnXn{IWR_}|YA=gLi86V)TyFdoa)n$er($BNI)?EYxmK=|>*dw*8aXXD
> z$c=K7+{`*!SkDGp*+?6k*vuBT(m^L(bkoB&dg-H|0S4L54tBDO-9(1i!(R5Wp936Z
> zm_r=q2uC@_aZWJ8Nk%!vY0hw#bDZY_7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X%L~GQ%StlVz4Up74}sJm&>3dBtnq@RoPHXP)q*{U?W9^2n!v
> zLXs4bqL>m&S;;EOSWP)=s9-IXRFS5JTI#5$f%P<!VFMf4L=&57W(!+sp_OfHX9qjk
> zMH}sO&`B42=%$BW`simb``FI`4iXvQ5QjO!QI0Xl5XU*eNltN^Gn{3Z5k@)3c`k5~
> zOI+p(SGmR**SWzs6HIcGDQ<C_J4|zzd)(&%51HW+kI6F298Y-4GoJH;m%QRNZ+Oc)
> z-ZTH>;=4l3jkDetl8OBINhn$PPsj}XVc{Jj>9hEqh>PveyTpPET^Spn35nqj4=99B
> z(|^tXGFHT8F|?;*)!4GQB&6a(Uzt3VNX4RI=k%r2oXS*8{;!c#T=I8))2Y~-O~uSo
> z?SJsMRBSBKKPdm84y58tMJkqloGVvdVa^<NxtdUysX_hSxP`To)?T=d5I(H`;l5Uc
> e`G1A75LQh5_qvVy&prQh@mz8uvp6pN-|=rm*n1xU
>
> literal 0
> HcmV?d00001
>
> diff --git a/rtl_nic/rtl8168h-2.fw b/rtl_nic/rtl8168h-2.fw
> new file mode 100644
> index 0000000000000000000000000000000000000000..949bacc1614d6e1014736611bd371ef30a3e8daf
> GIT binary patch
> literal 2464
> zcmYk;aY&Wt9tZHJGp}<_%-NYaZ)?&dB)oQXB2HQyoQVq;At4cw&N;6%5fO=qi08V9
> zh!zqN5fKs+5iKGjB)a02<{}~@A|fIVA`uZSA|fJeA6>ibJ?F#k`@HY_JkNXH=a2J*
> z5W>J<Z(UVwUC+O&+f$XP%Bs@Tmn*BPS60=yHg|OJZ6buPLTgLy7q!(5?TxM9w5@4v
> z@BeP_`=0iuz8?nL*Q{An`F;1lORH+?zo@EDRfnHP%jWtn2q8VW@Us{~4!Pu!PXUD_
> zDT?ofkcsZg$%MEtlZYQ>vf`plcKkS#6BlQ4<0qNC_|Hs!eE&E7J}r#XKPTh=nu}uM
> z*WwudTM}o&k~ooBs$HtREEXlo<mGa?@mI(da;2P#iK*%s#%ttSxlXQ^S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@&;fBmlC
> P=dTq^r04sE{~vz<lf`x)
>
> literal 0
> HcmV?d00001
>
^ permalink raw reply
* [net-next v7 4/4] l2tp: Refactor l2tp core driver to make use of the common UDP tunnel functions
From: Andy Zhou @ 2014-09-15 10:35 UTC (permalink / raw)
To: davem; +Cc: netdev, Andy Zhou
Signed-off-by: Andy Zhou <azhou@nicira.com>
---
net/l2tp/l2tp_core.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index 2aa2b6c..895348e 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -1392,8 +1392,6 @@ static int l2tp_tunnel_sock_create(struct net *net,
if (err < 0)
goto out;
- udp_set_convert_csum(sock->sk, true);
-
break;
case L2TP_ENCAPTYPE_IP:
@@ -1584,19 +1582,17 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
/* Mark socket as an encapsulation socket. See net/ipv4/udp.c */
tunnel->encap = encap;
if (encap == L2TP_ENCAPTYPE_UDP) {
- /* Mark socket as an encapsulation socket. See net/ipv4/udp.c */
- udp_sk(sk)->encap_type = UDP_ENCAP_L2TPINUDP;
- udp_sk(sk)->encap_rcv = l2tp_udp_encap_recv;
- udp_sk(sk)->encap_destroy = l2tp_udp_encap_destroy;
-#if IS_ENABLED(CONFIG_IPV6)
- if (sk->sk_family == PF_INET6 && !tunnel->v4mapped)
- udpv6_encap_enable();
- else
-#endif
- udp_encap_enable();
- }
+ struct udp_tunnel_sock_cfg udp_cfg;
+
+ udp_cfg.sk_user_data = tunnel;
+ udp_cfg.encap_type = UDP_ENCAP_L2TPINUDP;
+ udp_cfg.encap_rcv = l2tp_udp_encap_recv;
+ udp_cfg.encap_destroy = l2tp_udp_encap_destroy;
- sk->sk_user_data = tunnel;
+ setup_udp_tunnel_sock(net, sock, &udp_cfg);
+ } else {
+ sk->sk_user_data = tunnel;
+ }
/* Hook on the tunnel socket destructor so that we can cleanup
* if the tunnel socket goes away.
--
1.7.9.5
^ permalink raw reply related
* [net-next v7 3/4] vxlan: Refactor vxlan driver to make use of the common UDP tunnel functions.
From: Andy Zhou @ 2014-09-15 10:34 UTC (permalink / raw)
To: davem; +Cc: netdev, Andy Zhou
In-Reply-To: <1410777267-28237-1-git-send-email-azhou@nicira.com>
Signed-off-by: Andy Zhou <azhou@nicira.com>
---
drivers/net/vxlan.c | 105 +++++++++++----------------------------------------
1 file changed, 22 insertions(+), 83 deletions(-)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 53c3ec1..39c8653 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -42,6 +42,7 @@
#include <net/netns/generic.h>
#include <net/vxlan.h>
#include <net/protocol.h>
+#include <net/udp_tunnel.h>
#if IS_ENABLED(CONFIG_IPV6)
#include <net/ipv6.h>
#include <net/addrconf.h>
@@ -1062,7 +1063,6 @@ void vxlan_sock_release(struct vxlan_sock *vs)
spin_lock(&vn->sock_lock);
hlist_del_rcu(&vs->hlist);
- rcu_assign_sk_user_data(vs->sock->sk, NULL);
vxlan_notify_del_rx_port(vs);
spin_unlock(&vn->sock_lock);
@@ -1336,7 +1336,6 @@ out:
}
#if IS_ENABLED(CONFIG_IPV6)
-
static struct sk_buff *vxlan_na_create(struct sk_buff *request,
struct neighbour *n, bool isrouter)
{
@@ -1570,13 +1569,6 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
return false;
}
-static inline struct sk_buff *vxlan_handle_offloads(struct sk_buff *skb,
- bool udp_csum)
-{
- int type = udp_csum ? SKB_GSO_UDP_TUNNEL_CSUM : SKB_GSO_UDP_TUNNEL;
- return iptunnel_handle_offloads(skb, udp_csum, type);
-}
-
#if IS_ENABLED(CONFIG_IPV6)
static int vxlan6_xmit_skb(struct vxlan_sock *vs,
struct dst_entry *dst, struct sk_buff *skb,
@@ -1585,13 +1577,12 @@ static int vxlan6_xmit_skb(struct vxlan_sock *vs,
__be16 src_port, __be16 dst_port, __be32 vni,
bool xnet)
{
- struct ipv6hdr *ip6h;
struct vxlanhdr *vxh;
- struct udphdr *uh;
int min_headroom;
int err;
+ bool udp_sum = !udp_get_no_check6_tx(vs->sock->sk);
- skb = vxlan_handle_offloads(skb, !udp_get_no_check6_tx(vs->sock->sk));
+ skb = udp_tunnel_handle_offloads(skb, udp_sum);
if (IS_ERR(skb))
return -EINVAL;
@@ -1619,38 +1610,8 @@ static int vxlan6_xmit_skb(struct vxlan_sock *vs,
vxh->vx_flags = htonl(VXLAN_FLAGS);
vxh->vx_vni = vni;
- __skb_push(skb, sizeof(*uh));
- skb_reset_transport_header(skb);
- uh = udp_hdr(skb);
-
- uh->dest = dst_port;
- uh->source = src_port;
-
- uh->len = htons(skb->len);
-
- memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
- IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED |
- IPSKB_REROUTED);
- skb_dst_set(skb, dst);
-
- udp6_set_csum(udp_get_no_check6_tx(vs->sock->sk), skb,
- saddr, daddr, skb->len);
-
- __skb_push(skb, sizeof(*ip6h));
- skb_reset_network_header(skb);
- ip6h = ipv6_hdr(skb);
- ip6h->version = 6;
- ip6h->priority = prio;
- ip6h->flow_lbl[0] = 0;
- ip6h->flow_lbl[1] = 0;
- ip6h->flow_lbl[2] = 0;
- ip6h->payload_len = htons(skb->len);
- ip6h->nexthdr = IPPROTO_UDP;
- ip6h->hop_limit = ttl;
- ip6h->daddr = *daddr;
- ip6h->saddr = *saddr;
-
- ip6tunnel_xmit(skb, dev);
+ udp_tunnel6_xmit_skb(vs->sock, dst, skb, dev, saddr, daddr, prio,
+ ttl, src_port, dst_port);
return 0;
}
#endif
@@ -1661,11 +1622,11 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
__be16 src_port, __be16 dst_port, __be32 vni, bool xnet)
{
struct vxlanhdr *vxh;
- struct udphdr *uh;
int min_headroom;
int err;
+ bool udp_sum = !vs->sock->sk->sk_no_check_tx;
- skb = vxlan_handle_offloads(skb, !vs->sock->sk->sk_no_check_tx);
+ skb = udp_tunnel_handle_offloads(skb, udp_sum);
if (IS_ERR(skb))
return -EINVAL;
@@ -1691,20 +1652,8 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
vxh->vx_flags = htonl(VXLAN_FLAGS);
vxh->vx_vni = vni;
- __skb_push(skb, sizeof(*uh));
- skb_reset_transport_header(skb);
- uh = udp_hdr(skb);
-
- uh->dest = dst_port;
- uh->source = src_port;
-
- uh->len = htons(skb->len);
-
- udp_set_csum(vs->sock->sk->sk_no_check_tx, skb,
- src, dst, skb->len);
-
- return iptunnel_xmit(vs->sock->sk, rt, skb, src, dst, IPPROTO_UDP,
- tos, ttl, df, xnet);
+ return udp_tunnel_xmit_skb(vs->sock, rt, skb, src, dst, tos,
+ ttl, df, src_port, dst_port, xnet);
}
EXPORT_SYMBOL_GPL(vxlan_xmit_skb);
@@ -1829,11 +1778,11 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
tos = ip_tunnel_ecn_encap(tos, old_iph, skb);
ttl = ttl ? : ip4_dst_hoplimit(&rt->dst);
- err = vxlan_xmit_skb(vxlan->vn_sock, rt, skb,
- fl4.saddr, dst->sin.sin_addr.s_addr,
- tos, ttl, df, src_port, dst_port,
- htonl(vni << 8),
- !net_eq(vxlan->net, dev_net(vxlan->dev)));
+ err = udp_tunnel_xmit_skb(vxlan->vn_sock->sock, rt, skb,
+ fl4.saddr, dst->sin.sin_addr.s_addr,
+ tos, ttl, df, src_port, dst_port,
+ !net_eq(vxlan->net,
+ dev_net(vxlan->dev)));
if (err < 0)
goto rt_tx_error;
@@ -2333,8 +2282,7 @@ static const struct ethtool_ops vxlan_ethtool_ops = {
static void vxlan_del_work(struct work_struct *work)
{
struct vxlan_sock *vs = container_of(work, struct vxlan_sock, del_work);
-
- sk_release_kernel(vs->sock->sk);
+ udp_tunnel_sock_release(vs->sock);
kfree_rcu(vs, rcu);
}
@@ -2367,11 +2315,6 @@ static struct socket *vxlan_create_sock(struct net *net, bool ipv6,
if (err < 0)
return ERR_PTR(err);
- /* Disable multicast loopback */
- inet_sk(sock->sk)->mc_loop = 0;
-
- udp_set_convert_csum(sock->sk, true);
-
return sock;
}
@@ -2383,9 +2326,9 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port,
struct vxlan_net *vn = net_generic(net, vxlan_net_id);
struct vxlan_sock *vs;
struct socket *sock;
- struct sock *sk;
unsigned int h;
bool ipv6 = !!(flags & VXLAN_F_IPV6);
+ struct udp_tunnel_sock_cfg tunnel_cfg;
vs = kzalloc(sizeof(*vs), GFP_KERNEL);
if (!vs)
@@ -2403,11 +2346,9 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port,
}
vs->sock = sock;
- sk = sock->sk;
atomic_set(&vs->refcnt, 1);
vs->rcv = rcv;
vs->data = data;
- rcu_assign_sk_user_data(vs->sock->sk, vs);
/* Initialize the vxlan udp offloads structure */
vs->udp_offloads.port = port;
@@ -2420,14 +2361,12 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port,
spin_unlock(&vn->sock_lock);
/* Mark socket as an encapsulation socket. */
- udp_sk(sk)->encap_type = 1;
- udp_sk(sk)->encap_rcv = vxlan_udp_encap_recv;
-#if IS_ENABLED(CONFIG_IPV6)
- if (ipv6)
- ipv6_stub->udpv6_encap_enable();
- else
-#endif
- udp_encap_enable();
+ tunnel_cfg.sk_user_data = vs;
+ tunnel_cfg.encap_type = 1;
+ tunnel_cfg.encap_rcv = vxlan_udp_encap_recv;
+ tunnel_cfg.encap_destroy = NULL;
+
+ setup_udp_tunnel_sock(net, sock, &tunnel_cfg);
return vs;
}
--
1.7.9.5
^ permalink raw reply related
* [net-next v7 2/4] udp-tunnel: Expand UDP tunnel APIs
From: Andy Zhou @ 2014-09-15 10:34 UTC (permalink / raw)
To: davem; +Cc: netdev, Andy Zhou
In-Reply-To: <1410777267-28237-1-git-send-email-azhou@nicira.com>
Added common udp tunnel socket creation, and packet transmission APIs
API that can be used by other UDP based tunneling protocol
implementation.
Signed-off-by: Andy Zhou <azhou@nicira.com>
---
include/net/udp_tunnel.h | 55 +++++++++++++++++++++++++++++++++++++++++++++
net/ipv4/udp_tunnel.c | 53 ++++++++++++++++++++++++++++++++++++++++++-
net/ipv6/ip6_udp_tunnel.c | 42 ++++++++++++++++++++++++++++++++++
3 files changed, 149 insertions(+), 1 deletion(-)
diff --git a/include/net/udp_tunnel.h b/include/net/udp_tunnel.h
index 0b9e017..5f3837f 100644
--- a/include/net/udp_tunnel.h
+++ b/include/net/udp_tunnel.h
@@ -1,6 +1,14 @@
#ifndef __NET_UDP_TUNNEL_H
#define __NET_UDP_TUNNEL_H
+#include <net/ip_tunnels.h>
+#include <net/udp.h>
+
+#if IS_ENABLED(CONFIG_IPV6)
+#include <net/ipv6.h>
+#include <net/addrconf.h>
+#endif
+
struct udp_port_cfg {
u8 family;
@@ -53,4 +61,51 @@ static inline int udp_sock_create(struct net *net,
return -EPFNOSUPPORT;
}
+typedef int (*udp_tunnel_encap_rcv_t)(struct sock *sk, struct sk_buff *skb);
+typedef void (*udp_tunnel_encap_destroy_t)(struct sock *sk);
+
+struct udp_tunnel_sock_cfg {
+ void *sk_user_data; /* user data used by encap_rcv call back */
+ /* Used for setting up udp_sock fields, see udp.h for details */
+ __u8 encap_type;
+ udp_tunnel_encap_rcv_t encap_rcv;
+ udp_tunnel_encap_destroy_t encap_destroy;
+};
+
+void setup_udp_tunnel_sock(struct net *net, struct socket *sock,
+ struct udp_tunnel_sock_cfg *sock_cfg);
+
+int udp_tunnel_xmit_skb(struct socket *sock, struct rtable *rt,
+ struct sk_buff *skb, __be32 src, __be32 dst,
+ __u8 tos, __u8 ttl, __be16 df, __be16 src_port,
+ __be16 dst_port, bool xnet);
+
+#if IS_ENABLED(CONFIG_IPV6)
+int udp_tunnel6_xmit_skb(struct socket *sock, struct dst_entry *dst,
+ struct sk_buff *skb, struct net_device *dev,
+ struct in6_addr *saddr, struct in6_addr *daddr,
+ __u8 prio, __u8 ttl, __be16 src_port,
+ __be16 dst_port);
+#endif
+
+void udp_tunnel_sock_release(struct socket *sock);
+
+static inline struct sk_buff *udp_tunnel_handle_offloads(struct sk_buff *skb,
+ bool udp_csum)
+{
+ int type = udp_csum ? SKB_GSO_UDP_TUNNEL_CSUM : SKB_GSO_UDP_TUNNEL;
+
+ return iptunnel_handle_offloads(skb, udp_csum, type);
+}
+
+static inline void udp_tunnel_encap_enable(struct socket *sock)
+{
+#if IS_ENABLED(CONFIG_IPV6)
+ if (sock->sk->sk_family == PF_INET6)
+ ipv6_stub->udpv6_encap_enable();
+ else
+#endif
+ udp_encap_enable();
+}
+
#endif
diff --git a/net/ipv4/udp_tunnel.c b/net/ipv4/udp_tunnel.c
index 7fccf6c..1671263 100644
--- a/net/ipv4/udp_tunnel.c
+++ b/net/ipv4/udp_tunnel.c
@@ -11,7 +11,7 @@
int udp_sock_create4(struct net *net, struct udp_port_cfg *cfg,
struct socket **sockp)
{
- int err = -EINVAL;
+ int err;
struct socket *sock = NULL;
struct sockaddr_in udp_addr;
@@ -54,4 +54,55 @@ error:
}
EXPORT_SYMBOL(udp_sock_create4);
+void setup_udp_tunnel_sock(struct net *net, struct socket *sock,
+ struct udp_tunnel_sock_cfg *cfg)
+{
+ struct sock *sk = sock->sk;
+
+ /* Disable multicast loopback */
+ inet_sk(sk)->mc_loop = 0;
+
+ /* Enable CHECKSUM_UNNECESSARY to CHECKSUM_COMPLETE conversion */
+ udp_set_convert_csum(sk, true);
+
+ rcu_assign_sk_user_data(sk, cfg->sk_user_data);
+
+ udp_sk(sk)->encap_type = cfg->encap_type;
+ udp_sk(sk)->encap_rcv = cfg->encap_rcv;
+ udp_sk(sk)->encap_destroy = cfg->encap_destroy;
+
+ udp_tunnel_encap_enable(sock);
+}
+EXPORT_SYMBOL_GPL(setup_udp_tunnel_sock);
+
+int udp_tunnel_xmit_skb(struct socket *sock, struct rtable *rt,
+ struct sk_buff *skb, __be32 src, __be32 dst,
+ __u8 tos, __u8 ttl, __be16 df, __be16 src_port,
+ __be16 dst_port, bool xnet)
+{
+ struct udphdr *uh;
+
+ __skb_push(skb, sizeof(*uh));
+ skb_reset_transport_header(skb);
+ uh = udp_hdr(skb);
+
+ uh->dest = dst_port;
+ uh->source = src_port;
+ uh->len = htons(skb->len);
+
+ udp_set_csum(sock->sk->sk_no_check_tx, skb, src, dst, skb->len);
+
+ return iptunnel_xmit(sock->sk, rt, skb, src, dst, IPPROTO_UDP,
+ tos, ttl, df, xnet);
+}
+EXPORT_SYMBOL_GPL(udp_tunnel_xmit_skb);
+
+void udp_tunnel_sock_release(struct socket *sock)
+{
+ rcu_assign_sk_user_data(sock->sk, NULL);
+ kernel_sock_shutdown(sock, SHUT_RDWR);
+ sk_release_kernel(sock->sk);
+}
+EXPORT_SYMBOL_GPL(udp_tunnel_sock_release);
+
MODULE_LICENSE("GPL");
diff --git a/net/ipv6/ip6_udp_tunnel.c b/net/ipv6/ip6_udp_tunnel.c
index bcfbb4b..cbc9907 100644
--- a/net/ipv6/ip6_udp_tunnel.c
+++ b/net/ipv6/ip6_udp_tunnel.c
@@ -61,3 +61,45 @@ error:
return err;
}
EXPORT_SYMBOL_GPL(udp_sock_create6);
+
+int udp_tunnel6_xmit_skb(struct socket *sock, struct dst_entry *dst,
+ struct sk_buff *skb, struct net_device *dev,
+ struct in6_addr *saddr, struct in6_addr *daddr,
+ __u8 prio, __u8 ttl, __be16 src_port, __be16 dst_port)
+{
+ struct udphdr *uh;
+ struct ipv6hdr *ip6h;
+ struct sock *sk = sock->sk;
+
+ __skb_push(skb, sizeof(*uh));
+ skb_reset_transport_header(skb);
+ uh = udp_hdr(skb);
+
+ uh->dest = dst_port;
+ uh->source = src_port;
+
+ uh->len = htons(skb->len);
+ uh->check = 0;
+
+ memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
+ IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED
+ | IPSKB_REROUTED);
+ skb_dst_set(skb, dst);
+
+ udp6_set_csum(udp_get_no_check6_tx(sk), skb, &inet6_sk(sk)->saddr,
+ &sk->sk_v6_daddr, skb->len);
+
+ __skb_push(skb, sizeof(*ip6h));
+ skb_reset_network_header(skb);
+ ip6h = ipv6_hdr(skb);
+ ip6_flow_hdr(ip6h, prio, htonl(0));
+ ip6h->payload_len = htons(skb->len);
+ ip6h->nexthdr = IPPROTO_UDP;
+ ip6h->hop_limit = ttl;
+ ip6h->daddr = *daddr;
+ ip6h->saddr = *saddr;
+
+ ip6tunnel_xmit(skb, dev);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(udp_tunnel6_xmit_skb);
--
1.7.9.5
^ permalink raw reply related
* [net-next v7 1/4] udp_tunnel: Seperate ipv6 functions into its own file.
From: Andy Zhou @ 2014-09-15 10:34 UTC (permalink / raw)
To: davem; +Cc: netdev, Andy Zhou
In-Reply-To: <1410777267-28237-1-git-send-email-azhou@nicira.com>
Add ip6_udp_tunnel.c for ipv6 UDP tunnel functions to avoid ifdefs
in udp_tunnel.c
Signed-off-by: Andy Zhou <azhou@nicira.com>
---
include/net/udp_tunnel.h | 28 +++++++++++++--
net/ipv4/udp_tunnel.c | 85 +++++++++++----------------------------------
net/ipv6/Makefile | 1 +
net/ipv6/ip6_udp_tunnel.c | 63 +++++++++++++++++++++++++++++++++
4 files changed, 111 insertions(+), 66 deletions(-)
create mode 100644 net/ipv6/ip6_udp_tunnel.c
diff --git a/include/net/udp_tunnel.h b/include/net/udp_tunnel.h
index ffd69cb..0b9e017 100644
--- a/include/net/udp_tunnel.h
+++ b/include/net/udp_tunnel.h
@@ -26,7 +26,31 @@ struct udp_port_cfg {
use_udp6_rx_checksums:1;
};
-int udp_sock_create(struct net *net, struct udp_port_cfg *cfg,
- struct socket **sockp);
+int udp_sock_create4(struct net *net, struct udp_port_cfg *cfg,
+ struct socket **sockp);
+
+#if IS_ENABLED(CONFIG_IPV6)
+int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,
+ struct socket **sockp);
+#else
+static inline int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,
+ struct socket **sockp)
+{
+ return 0;
+}
+#endif
+
+static inline int udp_sock_create(struct net *net,
+ struct udp_port_cfg *cfg,
+ struct socket **sockp)
+{
+ if (cfg->family == AF_INET)
+ return udp_sock_create4(net, cfg, sockp);
+
+ if (cfg->family == AF_INET6)
+ return udp_sock_create6(net, cfg, sockp);
+
+ return -EPFNOSUPPORT;
+}
#endif
diff --git a/net/ipv4/udp_tunnel.c b/net/ipv4/udp_tunnel.c
index 61ec1a6..7fccf6c 100644
--- a/net/ipv4/udp_tunnel.c
+++ b/net/ipv4/udp_tunnel.c
@@ -8,83 +8,40 @@
#include <net/udp_tunnel.h>
#include <net/net_namespace.h>
-int udp_sock_create(struct net *net, struct udp_port_cfg *cfg,
- struct socket **sockp)
+int udp_sock_create4(struct net *net, struct udp_port_cfg *cfg,
+ struct socket **sockp)
{
int err = -EINVAL;
struct socket *sock = NULL;
+ struct sockaddr_in udp_addr;
-#if IS_ENABLED(CONFIG_IPV6)
- if (cfg->family == AF_INET6) {
- struct sockaddr_in6 udp6_addr;
+ err = sock_create_kern(AF_INET, SOCK_DGRAM, 0, &sock);
+ if (err < 0)
+ goto error;
- err = sock_create_kern(AF_INET6, SOCK_DGRAM, 0, &sock);
- if (err < 0)
- goto error;
-
- sk_change_net(sock->sk, net);
-
- udp6_addr.sin6_family = AF_INET6;
- memcpy(&udp6_addr.sin6_addr, &cfg->local_ip6,
- sizeof(udp6_addr.sin6_addr));
- udp6_addr.sin6_port = cfg->local_udp_port;
- err = kernel_bind(sock, (struct sockaddr *)&udp6_addr,
- sizeof(udp6_addr));
- if (err < 0)
- goto error;
-
- if (cfg->peer_udp_port) {
- udp6_addr.sin6_family = AF_INET6;
- memcpy(&udp6_addr.sin6_addr, &cfg->peer_ip6,
- sizeof(udp6_addr.sin6_addr));
- udp6_addr.sin6_port = cfg->peer_udp_port;
- err = kernel_connect(sock,
- (struct sockaddr *)&udp6_addr,
- sizeof(udp6_addr), 0);
- }
- if (err < 0)
- goto error;
-
- udp_set_no_check6_tx(sock->sk, !cfg->use_udp6_tx_checksums);
- udp_set_no_check6_rx(sock->sk, !cfg->use_udp6_rx_checksums);
- } else
-#endif
- if (cfg->family == AF_INET) {
- struct sockaddr_in udp_addr;
-
- err = sock_create_kern(AF_INET, SOCK_DGRAM, 0, &sock);
- if (err < 0)
- goto error;
+ sk_change_net(sock->sk, net);
- sk_change_net(sock->sk, net);
+ udp_addr.sin_family = AF_INET;
+ udp_addr.sin_addr = cfg->local_ip;
+ udp_addr.sin_port = cfg->local_udp_port;
+ err = kernel_bind(sock, (struct sockaddr *)&udp_addr,
+ sizeof(udp_addr));
+ if (err < 0)
+ goto error;
+ if (cfg->peer_udp_port) {
udp_addr.sin_family = AF_INET;
- udp_addr.sin_addr = cfg->local_ip;
- udp_addr.sin_port = cfg->local_udp_port;
- err = kernel_bind(sock, (struct sockaddr *)&udp_addr,
- sizeof(udp_addr));
+ udp_addr.sin_addr = cfg->peer_ip;
+ udp_addr.sin_port = cfg->peer_udp_port;
+ err = kernel_connect(sock, (struct sockaddr *)&udp_addr,
+ sizeof(udp_addr), 0);
if (err < 0)
goto error;
-
- if (cfg->peer_udp_port) {
- udp_addr.sin_family = AF_INET;
- udp_addr.sin_addr = cfg->peer_ip;
- udp_addr.sin_port = cfg->peer_udp_port;
- err = kernel_connect(sock,
- (struct sockaddr *)&udp_addr,
- sizeof(udp_addr), 0);
- if (err < 0)
- goto error;
- }
-
- sock->sk->sk_no_check_tx = !cfg->use_udp_checksums;
- } else {
- return -EPFNOSUPPORT;
}
+ sock->sk->sk_no_check_tx = !cfg->use_udp_checksums;
*sockp = sock;
-
return 0;
error:
@@ -95,6 +52,6 @@ error:
*sockp = NULL;
return err;
}
-EXPORT_SYMBOL(udp_sock_create);
+EXPORT_SYMBOL(udp_sock_create4);
MODULE_LICENSE("GPL");
diff --git a/net/ipv6/Makefile b/net/ipv6/Makefile
index 2fe6836..45f830e 100644
--- a/net/ipv6/Makefile
+++ b/net/ipv6/Makefile
@@ -35,6 +35,7 @@ obj-$(CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION) += xfrm6_mode_ro.o
obj-$(CONFIG_INET6_XFRM_MODE_BEET) += xfrm6_mode_beet.o
obj-$(CONFIG_IPV6_MIP6) += mip6.o
obj-$(CONFIG_NETFILTER) += netfilter/
+obj-$(CONFIG_NET_UDP_TUNNEL) += ip6_udp_tunnel.o
obj-$(CONFIG_IPV6_VTI) += ip6_vti.o
obj-$(CONFIG_IPV6_SIT) += sit.o
diff --git a/net/ipv6/ip6_udp_tunnel.c b/net/ipv6/ip6_udp_tunnel.c
new file mode 100644
index 0000000..bcfbb4b
--- /dev/null
+++ b/net/ipv6/ip6_udp_tunnel.c
@@ -0,0 +1,63 @@
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/socket.h>
+#include <linux/udp.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/in6.h>
+#include <net/udp.h>
+#include <net/udp_tunnel.h>
+#include <net/net_namespace.h>
+#include <net/netns/generic.h>
+#include <net/ip6_tunnel.h>
+#include <net/ip6_checksum.h>
+
+int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,
+ struct socket **sockp)
+{
+ struct sockaddr_in6 udp6_addr;
+ int err;
+ struct socket *sock = NULL;
+
+ err = sock_create_kern(AF_INET6, SOCK_DGRAM, 0, &sock);
+ if (err < 0)
+ goto error;
+
+ sk_change_net(sock->sk, net);
+
+ udp6_addr.sin6_family = AF_INET6;
+ memcpy(&udp6_addr.sin6_addr, &cfg->local_ip6,
+ sizeof(udp6_addr.sin6_addr));
+ udp6_addr.sin6_port = cfg->local_udp_port;
+ err = kernel_bind(sock, (struct sockaddr *)&udp6_addr,
+ sizeof(udp6_addr));
+ if (err < 0)
+ goto error;
+
+ if (cfg->peer_udp_port) {
+ udp6_addr.sin6_family = AF_INET6;
+ memcpy(&udp6_addr.sin6_addr, &cfg->peer_ip6,
+ sizeof(udp6_addr.sin6_addr));
+ udp6_addr.sin6_port = cfg->peer_udp_port;
+ err = kernel_connect(sock,
+ (struct sockaddr *)&udp6_addr,
+ sizeof(udp6_addr), 0);
+ }
+ if (err < 0)
+ goto error;
+
+ udp_set_no_check6_tx(sock->sk, !cfg->use_udp6_tx_checksums);
+ udp_set_no_check6_rx(sock->sk, !cfg->use_udp6_rx_checksums);
+
+ *sockp = sock;
+ return 0;
+
+error:
+ if (sock) {
+ kernel_sock_shutdown(sock, SHUT_RDWR);
+ sk_release_kernel(sock->sk);
+ }
+ *sockp = NULL;
+ return err;
+}
+EXPORT_SYMBOL_GPL(udp_sock_create6);
--
1.7.9.5
^ permalink raw reply related
* [net-next v7 0/4] Refactor vxlan and l2tp to use common UDP tunnel APIs
From: Andy Zhou @ 2014-09-15 10:34 UTC (permalink / raw)
To: davem; +Cc: netdev, Andy Zhou
Andy Zhou (4):
udp_tunnel: Seperate ipv6 functions into its own file.
udp-tunnel: Expand UDP tunnel APIs
vxlan: Refactor vxlan driver to make use of the common UDP tunnel
functions.
l2tp: Refactor l2tp core driver to make use of the common UDP tunnel
functions
drivers/net/vxlan.c | 105 ++++++++--------------------------
include/net/udp_tunnel.h | 83 ++++++++++++++++++++++++++-
net/ipv4/udp_tunnel.c | 138 ++++++++++++++++++++++++---------------------
net/ipv6/Makefile | 1 +
net/ipv6/ip6_udp_tunnel.c | 105 ++++++++++++++++++++++++++++++++++
net/l2tp/l2tp_core.c | 24 ++++----
6 files changed, 292 insertions(+), 164 deletions(-)
create mode 100644 net/ipv6/ip6_udp_tunnel.c
--
1.7.9.5
^ permalink raw reply
* [PATCHv2] ipv4: Do not cache routing failures due to disabled forwarding.
From: Nicolas Cavallari @ 2014-09-15 10:28 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Alexey Kuznetsov, James Morris,
Hideaki YOSHIFUJI, Patrick McHardy
In-Reply-To: <54143FB2.9000600@green-communications.fr>
If we cache them, the kernel will reuse them, independently of
whether forwarding is enabled or not. Which means that if forwarding is
disabled on the input interface where the first routing request comes
from, then that unreachable result will be cached and reused for
other interfaces, even if forwarding is enabled on them.
This can be verified with two interfaces A and B and an output interface
C, where B has forwarding enabled, but not A and trying
ip route get $dst iif A from $src && ip route get $dst iif B from $src
Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
---
v2: simplify patch using julian anastasov's suggestion.
net/ipv4/route.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 234a43e..b09fda8 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1798,6 +1798,7 @@ local_input:
no_route:
RT_CACHE_STAT_INC(in_no_route);
res.type = RTN_UNREACHABLE;
+ res.fi = NULL;
goto local_input;
/*
--
2.1.0
^ permalink raw reply related
* RE: curent state of GSO over IPv6 tunnel
From: Eric Dumazet @ 2014-09-15 10:29 UTC (permalink / raw)
To: Yuval Mintz; +Cc: netdev
In-Reply-To: <B5657A6538887040AD3A81F1008BEC63B366DB@avmb3.qlogic.org>
On Mon, 2014-09-15 at 10:19 +0000, Yuval Mintz wrote:
> > > Hi,
> > >
> > > Tried running simple scenarios using ipv6/ipv6 via gre-tunnel [ip6_gre].
> > >
> > > When I've tried sniffing Tx traffic [tcpdump] I've noticed there were
> > > no aggregations being set, i.e., only MTU-sized packets reached NIC.
> > >
> > > Looking at output of `ethtool -k', I can see `tx_gre_segmentation' is on.
> > >
> > > What's the current state of the feature? Is it feasible and I'm
> > > missing some configuration, or is it yet an unsupported feature?
> >
> > As far as I know, only bnx2x driver currently supports NETIF_F_GSO_GRE
> >
>
> Hi Eric,
>
> Might be true, but should this flag hold any sway over IPv6?
> [Both at the moment and in general, i.e., if it does not would we need
> an additional feature or simply extend the functionality so that it would
> effect IPv6 as well?]
Both ipv4 and ipv6 are supported under this single flag.
Really, in 2014 all NIC supporting TSO for GRE should support IPv6 as
well.
^ permalink raw reply
* [PATCH net] net: fix creation adjacent device symlinks
From: Alexander Fomichev @ 2014-09-15 10:22 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Cong Wang, Vlad Yasevich, Alexander Fomichev
In-Reply-To: <20140914.174507.2303420279405209295.davem@davemloft.net>
__netdev_adjacent_dev_insert may add adjust device of different net
namespace, without proper check it leads to emergence of broken
sysfs links from/to devices in another namespace.
Fix: rewrite netdev_adjacent_is_neigh_list macro as a function,
move net_eq check into netdev_adjacent_is_neigh_list.
(thanks David)
related to: 4c75431ac3520631f1d9e74aa88407e6374dbbc4
Signed-off-by: Alexander Fomichev <git.user@gmail.com>
---
net/core/dev.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index ab9a16530c36..00f15bc0a2ee 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4809,9 +4809,14 @@ static void netdev_adjacent_sysfs_del(struct net_device *dev,
sysfs_remove_link(&(dev->dev.kobj), linkname);
}
-#define netdev_adjacent_is_neigh_list(dev, dev_list) \
- (dev_list == &dev->adj_list.upper || \
- dev_list == &dev->adj_list.lower)
+static inline bool netdev_adjacent_is_neigh_list(struct net_device *dev,
+ struct net_device *adj_dev,
+ struct list_head *dev_list)
+{
+ return (dev_list == &dev->adj_list.upper ||
+ dev_list == &dev->adj_list.lower) &&
+ net_eq(dev_net(dev), dev_net(adj_dev));
+}
static int __netdev_adjacent_dev_insert(struct net_device *dev,
struct net_device *adj_dev,
@@ -4841,7 +4846,7 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
pr_debug("dev_hold for %s, because of link added from %s to %s\n",
adj_dev->name, dev->name, adj_dev->name);
- if (netdev_adjacent_is_neigh_list(dev, dev_list)) {
+ if (netdev_adjacent_is_neigh_list(dev, adj_dev, dev_list)) {
ret = netdev_adjacent_sysfs_add(dev, adj_dev, dev_list);
if (ret)
goto free_adj;
@@ -4862,7 +4867,7 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
return 0;
remove_symlinks:
- if (netdev_adjacent_is_neigh_list(dev, dev_list))
+ if (netdev_adjacent_is_neigh_list(dev, adj_dev, dev_list))
netdev_adjacent_sysfs_del(dev, adj_dev->name, dev_list);
free_adj:
kfree(adj);
@@ -4895,8 +4900,7 @@ static void __netdev_adjacent_dev_remove(struct net_device *dev,
if (adj->master)
sysfs_remove_link(&(dev->dev.kobj), "master");
- if (netdev_adjacent_is_neigh_list(dev, dev_list) &&
- net_eq(dev_net(dev),dev_net(adj_dev)))
+ if (netdev_adjacent_is_neigh_list(dev, adj_dev, dev_list))
netdev_adjacent_sysfs_del(dev, adj_dev->name, dev_list);
list_del_rcu(&adj->list);
--
2.1.0
^ permalink raw reply related
* RE: curent state of GSO over IPv6 tunnel
From: Yuval Mintz @ 2014-09-15 10:19 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev
In-Reply-To: <1410776054.7106.141.camel@edumazet-glaptop2.roam.corp.google.com>
> > Hi,
> >
> > Tried running simple scenarios using ipv6/ipv6 via gre-tunnel [ip6_gre].
> >
> > When I've tried sniffing Tx traffic [tcpdump] I've noticed there were
> > no aggregations being set, i.e., only MTU-sized packets reached NIC.
> >
> > Looking at output of `ethtool -k', I can see `tx_gre_segmentation' is on.
> >
> > What's the current state of the feature? Is it feasible and I'm
> > missing some configuration, or is it yet an unsupported feature?
>
> As far as I know, only bnx2x driver currently supports NETIF_F_GSO_GRE
>
Hi Eric,
Might be true, but should this flag hold any sway over IPv6?
[Both at the moment and in general, i.e., if it does not would we need
an additional feature or simply extend the functionality so that it would
effect IPv6 as well?]
Thanks,
Yuval
^ permalink raw reply
* Re: [PATCH net] net: fix sysfs symlinks of adjacent devices
From: Alexander Y. Fomichev @ 2014-09-15 10:18 UTC (permalink / raw)
To: David Miller; +Cc: vyasevich, netdev, Cong Wang, vyasevic, Andres Freund
In-Reply-To: <20140914.174507.2303420279405209295.davem@davemloft.net>
tnx, i had thinking move it to netdev_adjacent_sysfs_add/del.. but
this is better.
On Mon, Sep 15, 2014 at 1:45 AM, David Miller <davem@davemloft.net> wrote:
> From: Vlad Yasevich <vyasevich@gmail.com>
> Date: Fri, 12 Sep 2014 09:33:39 -0400
>
>> Looking over the code, it might make sense to move all the net_eq checks
>> into adjacent_sysfs calls so as to consolidate them. I haven't audited
>> all code paths, but at first glance it should do the right thing.
>>
>> What do you think?
>
> Agreed, let's do the following then?
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index ab9a165..a70e49e 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -4809,9 +4809,14 @@ static void netdev_adjacent_sysfs_del(struct net_device *dev,
> sysfs_remove_link(&(dev->dev.kobj), linkname);
> }
>
> -#define netdev_adjacent_is_neigh_list(dev, dev_list) \
> - (dev_list == &dev->adj_list.upper || \
> - dev_list == &dev->adj_list.lower)
> +static bool netdev_adjacent_is_neigh_list(struct net_device *dev,
> + struct net_device *adj_dev,
> + struct list_head *dev_list)
> +{
> + return (dev_list == &dev->adj_list.upper ||
> + dev_list == &dev->adj_list.lower) &&
> + net_eq(dev_net(dev), dev_net(adj_dev));
> +}
>
> static int __netdev_adjacent_dev_insert(struct net_device *dev,
> struct net_device *adj_dev,
> @@ -4841,7 +4846,7 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
> pr_debug("dev_hold for %s, because of link added from %s to %s\n",
> adj_dev->name, dev->name, adj_dev->name);
>
> - if (netdev_adjacent_is_neigh_list(dev, dev_list)) {
> + if (netdev_adjacent_is_neigh_list(dev, adj_dev, dev_list)) {
> ret = netdev_adjacent_sysfs_add(dev, adj_dev, dev_list);
> if (ret)
> goto free_adj;
> @@ -4862,7 +4867,7 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
> return 0;
>
> remove_symlinks:
> - if (netdev_adjacent_is_neigh_list(dev, dev_list))
> + if (netdev_adjacent_is_neigh_list(dev, adj_dev, dev_list))
> netdev_adjacent_sysfs_del(dev, adj_dev->name, dev_list);
> free_adj:
> kfree(adj);
> @@ -4895,8 +4900,7 @@ static void __netdev_adjacent_dev_remove(struct net_device *dev,
> if (adj->master)
> sysfs_remove_link(&(dev->dev.kobj), "master");
>
> - if (netdev_adjacent_is_neigh_list(dev, dev_list) &&
> - net_eq(dev_net(dev),dev_net(adj_dev)))
> + if (netdev_adjacent_is_neigh_list(dev, adj_dev, dev_list))
> netdev_adjacent_sysfs_del(dev, adj_dev->name, dev_list);
>
> list_del_rcu(&adj->list);
--
Best regards.
Alexander Y. Fomichev <git.user@gmail.com>
^ permalink raw reply
* Re: curent state of GSO over IPv6 tunnel
From: Eric Dumazet @ 2014-09-15 10:14 UTC (permalink / raw)
To: Yuval Mintz; +Cc: netdev
In-Reply-To: <B5657A6538887040AD3A81F1008BEC63B365F6@avmb3.qlogic.org>
On Mon, 2014-09-15 at 08:55 +0000, Yuval Mintz wrote:
> Hi,
>
> Tried running simple scenarios using ipv6/ipv6 via gre-tunnel [ip6_gre].
>
> When I've tried sniffing Tx traffic [tcpdump] I've noticed there were
> no aggregations being set, i.e., only MTU-sized packets reached NIC.
>
> Looking at output of `ethtool -k', I can see `tx_gre_segmentation' is on.
>
> What's the current state of the feature? Is it feasible and I'm missing
> some configuration, or is it yet an unsupported feature?
As far as I know, only bnx2x driver currently supports NETIF_F_GSO_GRE
^ permalink raw reply
* Re: [PATCH v3] net/phy: micrel: Disable asymmetric pause for KSZ9031
From: Mike Looijmans @ 2014-09-15 10:07 UTC (permalink / raw)
To: f.fainelli, netdev; +Cc: linux-kernel, Mike Looijmans
In-Reply-To: <1410775594-3129-1-git-send-email-mike.looijmans@topic.nl>
I based this patch on the 3.17rc5 state. Hope this applies cleanly now?
On 09/15/2014 12:06 PM, Mike Looijmans wrote:
> The KSZ9031 appears to suffer from the same hardware bug as described
> for the KSZ9021 in commit 32fcafbcd1c9f6c7013016a22a5369b4acb93577
> ("net/phy: micrel: Disable asymmetric pause for KSZ9021")
> you have to unplug the cable and plug it back to get it to work.
>
> Remove the SUPPORTED_Asym_Pause flag for the KSZ9031 to fix this.
>
> Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
> ---
> drivers/net/phy/micrel.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index fd0ea7c..011dbda 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -592,8 +592,7 @@ static struct phy_driver ksphy_driver[] = {
> .phy_id = PHY_ID_KSZ9031,
> .phy_id_mask = 0x00fffff0,
> .name = "Micrel KSZ9031 Gigabit PHY",
> - .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause
> - | SUPPORTED_Asym_Pause),
> + .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause),
> .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
> .config_init = ksz9031_config_init,
> .config_aneg = genphy_config_aneg,
>
Met vriendelijke groet / kind regards,
Mike Looijmans
TOPIC Embedded Systems
Eindhovenseweg 32-C, NL-5683 KH Best
Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: mike.looijmans@topic.nl
Website: www.topic.nl
Please consider the environment before printing this e-mail
Topic zoekt gedreven (embedded) software specialisten!
http://topic.nl/vacatures/topic-zoekt-software-engineers/
^ permalink raw reply
* [PATCH v3] net/phy: micrel: Disable asymmetric pause for KSZ9031
From: Mike Looijmans @ 2014-09-15 10:06 UTC (permalink / raw)
To: f.fainelli, netdev; +Cc: linux-kernel, Mike Looijmans
In-Reply-To: <20140912.181820.1440041146938289489.davem@davemloft.net>
The KSZ9031 appears to suffer from the same hardware bug as described
for the KSZ9021 in commit 32fcafbcd1c9f6c7013016a22a5369b4acb93577
("net/phy: micrel: Disable asymmetric pause for KSZ9021")
you have to unplug the cable and plug it back to get it to work.
Remove the SUPPORTED_Asym_Pause flag for the KSZ9031 to fix this.
Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
---
drivers/net/phy/micrel.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index fd0ea7c..011dbda 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -592,8 +592,7 @@ static struct phy_driver ksphy_driver[] = {
.phy_id = PHY_ID_KSZ9031,
.phy_id_mask = 0x00fffff0,
.name = "Micrel KSZ9031 Gigabit PHY",
- .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause
- | SUPPORTED_Asym_Pause),
+ .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause),
.flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
.config_init = ksz9031_config_init,
.config_aneg = genphy_config_aneg,
--
1.7.9.5
^ permalink raw reply related
* curent state of GSO over IPv6 tunnel
From: Yuval Mintz @ 2014-09-15 8:55 UTC (permalink / raw)
To: netdev
Hi,
Tried running simple scenarios using ipv6/ipv6 via gre-tunnel [ip6_gre].
When I've tried sniffing Tx traffic [tcpdump] I've noticed there were
no aggregations being set, i.e., only MTU-sized packets reached NIC.
Looking at output of `ethtool -k', I can see `tx_gre_segmentation' is on.
What's the current state of the feature? Is it feasible and I'm missing
some configuration, or is it yet an unsupported feature?
Thanks,
Yuval
________________________________
This message and any attached documents contain information from QLogic Corporation or its wholly-owned subsidiaries that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.
^ permalink raw reply
* Re: [PATCH net-next 04/14] tipc: add sock dump to new netlink api
From: Florian Westphal @ 2014-09-15 8:51 UTC (permalink / raw)
To: Richard Alpe; +Cc: David Miller, netdev, tipc-discussion
In-Reply-To: <54169B6C.5060709@ericsson.com>
Richard Alpe <richard.alpe@ericsson.com> wrote:
> >You can't just say sometimes you'll partially list the set of nested
> >attributes in an object, you must public the entire object fully in
> >the netlink message or skip the object entirely.
> Ok. I bluntly assumed we could put some reassemble logic in the
> client as the end integrity should still be preserved(?).
>
> >I would suggest that you instead size the amount of space you'll
> >need for at least the first socket being listed, and if NLMSG_GOODSIZE
> >is insufficient, allocate as much as you will actually need.
> >
> >Then you put full socket netlink blobs in there, including all nested
> >attributes, and then stop and reset back the the most recent full socket
> >published if you run out of space.
> The amount of publications a socket can have is large (~65 000). Do
> you still think this a viable solution?
I suggest to look at nf_conntrack_netlink.c ctnetlink_dump_table() and
ctnetlink_fill_info().
It should be doing something similar to what you want and it handles
the restarts correctly, i.e., cancels all partial nested attributes
on error and resumes at the beginning of said entry on the next dump.
^ permalink raw reply
* RE: [PATCH] net: can: usb: peak_usb: pcan_usb_core.c: Cleaning up missing null-terminate in conjunction with strncpy
From: David Laight @ 2014-09-15 8:47 UTC (permalink / raw)
To: 'Marc Kleine-Budde', 'Rickard Strandqvist',
Wolfgang Grandegger
Cc: Oliver Hartkopp, Stephane Grosjean, Alexey Khoroshilov,
Christopher R. Baker, linux-can@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <5416A65D.6010500@pengutronix.de>
From: Marc Kleine-Budde [
> On 09/15/2014 10:28 AM, David Laight wrote:
> > From: Rickard Strandqvist
> > ...
> >> Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
> > ...
> >> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> >> b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> >> index 644e6ab..d4fe8ac 100644
> >> --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> >> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> >> @@ -830,7 +830,7 @@ static void peak_usb_disconnect(struct usb_interface *intf)
> >> char name[IFNAMSIZ];
> >>
> >> dev->state &= ~PCAN_USB_STATE_CONNECTED;
> >> - strncpy(name, netdev->name, IFNAMSIZ);
> >> + strlcpy(name, netdev->name, IFNAMSIZ);
> >>
> >> unregister_netdev(netdev);
> >> free_candev(netdev);
> >
> > Or:
> > char name[sizeof netdev->name];
> > memcpy(name, netdev->name, sizeof netdev->name);
>
> I would be "sizeof(foo)" in kernel coding style,
But not in mine :-)
sizeof is an operator, not a function, it's argument can be (type).
> but let's have a look at the original code:
>
> struct net_device *netdev = dev->netdev;
> char name[IFNAMSIZ];
>
> dev->state &= ~PCAN_USB_STATE_CONNECTED;
> strncpy(name, netdev->name, IFNAMSIZ);
>
> unregister_netdev(netdev);
> free_candev(netdev);
>
> kfree(dev->cmd_buf);
> dev->next_siblings = NULL;
> if (dev->adapter->dev_free)
> dev->adapter->dev_free(dev);
>
> dev_info(&intf->dev, "%s removed\n", name);
>
> I think it's save to use:
>
> dev_info(&intf->dev, "%s removed\n", netdev_name(dev->netdev));
>
> instead of doing the str?cpy() in the first place. But why not use:
>
> netdev_info(dev->netdev, "removed\n");
>
> Is the USB device information lost when using netdev_info()?
My guess is it avoids a 'use after free' - but I'm not going to
dig that far.
Another issue with blindly replacing strncpy() with strlcpy()
(which doesn't affect the above) is when copying status to userspace.
David
^ permalink raw reply
* Re: [PATCH] net: can: usb: peak_usb: pcan_usb_core.c: Cleaning up missing null-terminate in conjunction with strncpy
From: Marc Kleine-Budde @ 2014-09-15 8:42 UTC (permalink / raw)
To: David Laight, 'Rickard Strandqvist', Wolfgang Grandegger
Cc: Oliver Hartkopp, Stephane Grosjean, Alexey Khoroshilov,
Christopher R. Baker, linux-can@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D17491F2B@AcuExch.aculab.com>
[-- Attachment #1: Type: text/plain, Size: 2053 bytes --]
On 09/15/2014 10:28 AM, David Laight wrote:
> From: Rickard Strandqvist
> ...
>> Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
> ...
>> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
>> b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
>> index 644e6ab..d4fe8ac 100644
>> --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
>> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
>> @@ -830,7 +830,7 @@ static void peak_usb_disconnect(struct usb_interface *intf)
>> char name[IFNAMSIZ];
>>
>> dev->state &= ~PCAN_USB_STATE_CONNECTED;
>> - strncpy(name, netdev->name, IFNAMSIZ);
>> + strlcpy(name, netdev->name, IFNAMSIZ);
>>
>> unregister_netdev(netdev);
>> free_candev(netdev);
>
> Or:
> char name[sizeof netdev->name];
> memcpy(name, netdev->name, sizeof netdev->name);
I would be "sizeof(foo)" in kernel coding style, but let's have a look
at the original code:
struct net_device *netdev = dev->netdev;
char name[IFNAMSIZ];
dev->state &= ~PCAN_USB_STATE_CONNECTED;
strncpy(name, netdev->name, IFNAMSIZ);
unregister_netdev(netdev);
free_candev(netdev);
kfree(dev->cmd_buf);
dev->next_siblings = NULL;
if (dev->adapter->dev_free)
dev->adapter->dev_free(dev);
dev_info(&intf->dev, "%s removed\n", name);
I think it's save to use:
dev_info(&intf->dev, "%s removed\n", netdev_name(dev->netdev));
instead of doing the str?cpy() in the first place. But why not use:
netdev_info(dev->netdev, "removed\n");
Is the USB device information lost when using netdev_info()?
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply
* Re: [PATCH] crypto: talitos: Avoid excessive loops in softirq context
From: Helmut Schaa @ 2014-09-15 8:40 UTC (permalink / raw)
To: Kim Phillips
Cc: linux-crypto, Herbert Xu, David Miller, Sandeep Malik,
Horia Geanta, netdev
In-Reply-To: <20140912182126.2d913df25f491416c3a1a677@freescale.com>
On Sat, Sep 13, 2014 at 1:21 AM, Kim Phillips
<kim.phillips@freescale.com> wrote:
> [adding Sandeep, Horia and netdev]
>
> On Fri, 12 Sep 2014 09:39:12 +0200
> Helmut Schaa <helmut.schaa@googlemail.com> wrote:
>
>> On Fri, Sep 12, 2014 at 2:49 AM, Kim Phillips
>> <kim.phillips@freescale.com> wrote:
>> > On Wed, 10 Sep 2014 10:34:47 +0200
>> > Helmut Schaa <helmut.schaa@googlemail.com> wrote:
>> >
>> >> The talitos driver can cause starvation of other softirqs and as such
>> >> it can also cause rcu stalls like:
>> > ...
>> >> Work around this by processing a maximum amount of 16 finished requests
>> >> and rescheduling the done-tasklet if any work is left.
>> >> This allows other softirqs to run.
>> >
>> > 16 sounds rather arbitrary, and application-dependent - talitos'
>> > FIFO size is 24.
>>
>> Yep, 16 is arbitrary, I can also do "fifo_len" if you prefer?
>>
>> > IIRC, netdev's NAPI can be refactored out of just being able to work
>> > on network devices, and be made to apply to crypto devices, too. In
>> > fact, some old Freescale hacks of this nature have improved
>> > performance. Can we do something like refactor NAPI instead?
>>
>> That would indeed be nice but sounds like quite some more work and
>> I won't have time to do so. Especially since my system was taken down
>> completely by the talitos tasklet under some circumstances. If there is
>> any work going on in that regard I'd be fine with just dropping that patch
>> (and carrying it myself until the refactoring is done).
>
> I'm not aware of any, but to prove whether NAPI actually fixes the
> issue, can you try applying this patch:
> http://patchwork.ozlabs.org/patch/146094/
I guess this would fix it too. Will run some tests soon.
Helmut
^ permalink raw reply
* Re: [net-next PATCH 00/12] net/sched rcu classifiers and tcf
From: Daniel Borkmann @ 2014-09-15 8:33 UTC (permalink / raw)
To: David Miller
Cc: john.fastabend, xiyou.wangcong, eric.dumazet, jhs, netdev,
paulmck, brouer
In-Reply-To: <20140913.123831.1668616111639540979.davem@davemloft.net>
On 09/13/2014 06:38 PM, David Miller wrote:
> From: John Fastabend <john.fastabend@gmail.com>
> Date: Fri, 12 Sep 2014 20:04:20 -0700
>
>> This series converts the tcf_proto usage to RCU.
>
> Series applied, thanks John!
Btw, a bit odd that Git shows all commits from 'net: qdisc: use rcu prefix
and silence sparse warnings' up to 'net: sched: rcu'ify cls_bpf' twice in
the log with only one Merge commit of diffstat -0/+0, e.g.:
https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=9888faefe1327909f3acf34d1feda87a368bb858
https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=c8b9affec519d27ce202a7ed22617eecbd96f127
^ permalink raw reply
* RE: [PATCH] net: can: usb: peak_usb: pcan_usb_core.c: Cleaning up missing null-terminate in conjunction with strncpy
From: David Laight @ 2014-09-15 8:28 UTC (permalink / raw)
To: 'Rickard Strandqvist', Wolfgang Grandegger,
Marc Kleine-Budde
Cc: Oliver Hartkopp, Stephane Grosjean, Alexey Khoroshilov,
Christopher R. Baker, linux-can@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <1410715898-15904-1-git-send-email-rickard_strandqvist@spectrumdigital.se>
From: Rickard Strandqvist
...
> Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
...
> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> index 644e6ab..d4fe8ac 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> @@ -830,7 +830,7 @@ static void peak_usb_disconnect(struct usb_interface *intf)
> char name[IFNAMSIZ];
>
> dev->state &= ~PCAN_USB_STATE_CONNECTED;
> - strncpy(name, netdev->name, IFNAMSIZ);
> + strlcpy(name, netdev->name, IFNAMSIZ);
>
> unregister_netdev(netdev);
> free_candev(netdev);
Or:
char name[sizeof netdev->name];
memcpy(name, netdev->name, sizeof netdev->name);
David
^ permalink raw reply
* Re: [BUG REPORT] Unencrypted packets after SNAT, allthough IPSEC-Policies are present
From: Steffen Klassert @ 2014-09-15 8:09 UTC (permalink / raw)
To: Konstantinos Kolelis
Cc: netdev, davem, kuznet, jmorris, yoshfuji, kaber, herbert
In-Reply-To: <20140912093143.GN6390@secunet.com>
On Fri, Sep 12, 2014 at 11:31:43AM +0200, Steffen Klassert wrote:
> On Thu, Sep 11, 2014 at 03:11:17PM +0200, Konstantinos Kolelis wrote:
> > Am 11.09.2014 13:54, schrieb Steffen Klassert:
> > > On Wed, Sep 10, 2014 at 07:26:53PM +0200, Konstantinos Kolelis wrote:
> > >> Hi all,
> > >>
> > >> i' ve observed a problem with xfrm lookups, SNAT, blackhole route and
> > >> missing SAs.
> > >> The problem occures with all Kernels above 3.6.x and might has to do
> > >> with the changes in
> > >> ip4_blackhole_route() function in net/route.c.
> > >
> > > Thanks for the report!
> > >
> > > Is kernel v3.6 the first kernel with this issue? It seems that
> > > we have this problem already longer, at least if my analysis
> > > is correct.
> > >
> >
> > It worked until Kernel 3.4.103, i did not check with v3.5 though.
>
> Hm. I thought the problem exists already for longer, so I did
> a bisect. To my surprise, the following commit introduced the bug:
>
> commit a263b3093641fb1ec377582c90986a7fd0625184
> Author: David S. Miller <davem@davemloft.net>
> Date: Mon Jul 2 02:02:15 2012 -0700
>
> ipv4: Make neigh lookups directly in output packet path.
>
> Do not use the dst cached neigh, we'll be getting rid of that.
>
> Signed-off-by: David S. Miller <davem@davemloft.net>
>
> But this is not really the offending commit. As I said, the problem
> was introduced by git commit 2774c131 ("xfrm: Handle blackhole route
> creation via afinfo.") because the assumption that dst_output() is
> called always after a xfrm_lookup() is wrong. On postrouting nat,
> dst_output() is not called for blackholed packets. But we were in luck
> because ip_finish_output2() tried to use a dst cached neigh entry.
> On blackhole routes we did not cache neigh entries, so the packets
> were dropped in the last moment. The above commit finally opened the
> door by replacing the usage of a dst cached neigh entry by a direct
> lookup.
>
> So we need to ensure that a blackhole route is generated only by the
> route lookup functions.
Can you please try the patch below? This should fix the default case
where xfrm_larval_drop is true. The xfrm_larval_drop false case needs
a separate fix.
Subject: [PATCH] xfrm: Generate blackhole routes only from route lookup
functions
Currently we genarate a blackhole route route whenever we have
matching policies but can not resolve the states. Here we assume
that dst_output() is called to kill the balckholed packets.
Unfortunately this assumption is not true in all cases, so
it is possible that these packets leave the system unwanted.
We fix this by generating blackhole routes only from the
route lookup functions, here we can guarantee a call to
dst_output() afterwards.
Fixes: 2774c131b1d ("xfrm: Handle blackhole route creation via afinfo.")
Reported-by: Konstantinos Kolelis <k.kolelis@sirrix.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
include/net/dst.h | 15 ++++++++++++++-
net/ipv4/route.c | 6 +++---
net/ipv6/ip6_output.c | 4 ++--
net/xfrm/xfrm_policy.c | 16 +++++++++++++++-
4 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/include/net/dst.h b/include/net/dst.h
index 71c60f4..fa11c90 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -490,7 +490,16 @@ static inline struct dst_entry *xfrm_lookup(struct net *net,
int flags)
{
return dst_orig;
-}
+}
+
+static inline struct dst_entry *xfrm_lookup_route(struct net *net,
+ struct dst_entry *dst_orig,
+ const struct flowi *fl,
+ struct sock *sk,
+ int flags)
+{
+ return dst_orig;
+}
static inline struct xfrm_state *dst_xfrm(const struct dst_entry *dst)
{
@@ -502,6 +511,10 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
const struct flowi *fl, struct sock *sk,
int flags);
+struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig,
+ const struct flowi *fl, struct sock *sk,
+ int flags);
+
/* skb attached with this dst needs transformation if dst->xfrm is valid */
static inline struct xfrm_state *dst_xfrm(const struct dst_entry *dst)
{
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index eaa4b00..173e7ea 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2265,9 +2265,9 @@ struct rtable *ip_route_output_flow(struct net *net, struct flowi4 *flp4,
return rt;
if (flp4->flowi4_proto)
- rt = (struct rtable *) xfrm_lookup(net, &rt->dst,
- flowi4_to_flowi(flp4),
- sk, 0);
+ rt = (struct rtable *)xfrm_lookup_route(net, &rt->dst,
+ flowi4_to_flowi(flp4),
+ sk, 0);
return rt;
}
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 315a55d..0a3448b 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1009,7 +1009,7 @@ struct dst_entry *ip6_dst_lookup_flow(struct sock *sk, struct flowi6 *fl6,
if (final_dst)
fl6->daddr = *final_dst;
- return xfrm_lookup(sock_net(sk), dst, flowi6_to_flowi(fl6), sk, 0);
+ return xfrm_lookup_route(sock_net(sk), dst, flowi6_to_flowi(fl6), sk, 0);
}
EXPORT_SYMBOL_GPL(ip6_dst_lookup_flow);
@@ -1041,7 +1041,7 @@ struct dst_entry *ip6_sk_dst_lookup_flow(struct sock *sk, struct flowi6 *fl6,
if (final_dst)
fl6->daddr = *final_dst;
- return xfrm_lookup(sock_net(sk), dst, flowi6_to_flowi(fl6), sk, 0);
+ return xfrm_lookup_route(sock_net(sk), dst, flowi6_to_flowi(fl6), sk, 0);
}
EXPORT_SYMBOL_GPL(ip6_sk_dst_lookup_flow);
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index beeed60..e041822 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -2138,7 +2138,8 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
xfrm_pols_put(pols, drop_pols);
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTNOSTATES);
- return make_blackhole(net, family, dst_orig);
+ err = -EREMOTE;
+ goto error;
}
err = -EAGAIN;
@@ -2195,6 +2196,19 @@ dropdst:
}
EXPORT_SYMBOL(xfrm_lookup);
+struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig,
+ const struct flowi *fl,
+ struct sock *sk, int flags)
+{
+ struct dst_entry *dst = xfrm_lookup(net, dst_orig, fl, sk, flags);
+
+ if (IS_ERR(dst) && PTR_ERR(dst) == -EREMOTE)
+ return make_blackhole(net, dst_orig->ops->family, dst_orig);
+
+ return dst;
+}
+EXPORT_SYMBOL(xfrm_lookup_route);
+
static inline int
xfrm_secpath_reject(int idx, struct sk_buff *skb, const struct flowi *fl)
{
--
1.9.1
^ permalink raw reply related
* Re: BCM4313 & brcmsmac & 3.12: only semi-working?
From: Arend van Spriel @ 2014-09-15 8:03 UTC (permalink / raw)
To: Michael Tokarev; +Cc: brcm80211-dev-list, linux-wireless, netdev
In-Reply-To: <53FDF8EB.4050905@broadcom.com>
On 27-08-14 17:27, Arend van Spriel wrote:
> On 08/27/14 12:02, Michael Tokarev wrote:
>> 27.08.2014 01:37, Arend van Spriel wrote:
>>> On 08/26/14 18:15, Michael Tokarev wrote:
>> []
>>> Well, sorry about that. I did see the other messages fly by and
>>> noticed you were using the wl driver so assumed you were fine with that.
>>
>> That's past already. I had several issues with wl driver,
>> and current issue is that even the latest (Aug-2014) version
>> of wl driver doesn't work with current kernel. So I can't
>> really even compare wl and brcmsmac, -- in kernels< 3.16
>> brcmsmac does not work, but wl can't be compiled for 3.16,
>> and using different kernels for comparison is a bit wrong
>> because there may be differences in other areas.
>>
>>> Admittedly the brcmsmac got very little attention as all our
>>> resources were put on brcmfmac.
>>
>> That happens. :)
>>
>> []
>>> Ok. Let's put frustration aside and make an effort. So could you make
>>> a trace using trace-cmd utility. The log can get quite big. The
>>> brcmsmac driver needs to be built with CONFIG_BRCM_TRACING enabled.
>>> Please execute the following commands (assuming you use ubuntu with
>>> network-manager):
>>>
>>> $ sudo stop network-manager
>>> $ sudo insmod brcmfmac.ko
>>> $ sudo trace-cmd record -e brcmsmac:*
>>>
>>> In another terminal:
>>>
>>> $ sudo start network-manager
>>>
>>> The trace-cmd must be stopped using ctrl-c.
>>
>> Okay. This turned out to be not so simple.
>>
>> My initial attempt indicated that brcmsmac in 3.16 does
>> not work at all. This isn't actually true - subsequent
>> attempts shows that it works. I was ready to conclude
>> the problem is fixed (after transferring several gigs
>> of data over wifi, with tracing enabled or disabled,
>> after fresh boot or after reboot from wl-enabled kernel,
>> etc - it all worked.
>>
>> Until I hit the same stall as I described initially, the
>> same which happened numerous times with kernel 3.12 ($subj).
>>
>> After several mins of transferring it stalled. But this
>> time (unlike with 3.12), it continued after about 30 secs.
>
> A kernel log (so no trace) of stalling interface might be useful so if
> you can provide that and put a marker in there where you believe it
> stalled that would be great.
Hi Michael,
Did you have any opportunity to create a log file. Got a question from
someone else who got bad bcm4313 behaviour after a certain upgrade. Did
you have the same experience?
Regards,
Arend
>> So, while my initial test of 3.16 indicated the prob is still
>> here, at the same (or even worse) state, I can't really
>> reproduce it, at least in a reliable way. There's something
>> wrong still, but at least current version is significantly
>> more useful than before (in a hope it wont stall at the
>> very wrong moment exactly ;).
>>
>> There's one more difference between brcmsmac and wl -- with
>> wl, I see significantly better speed, -- it is about 5MB/sec,
>> while with brcmsmac it jumps between 2.0..4.5MB/sec (with
>> 58..65Mbps connection rate in both cases). Here's a typical
>> iwconfig output for brcmsmac version:
>>
>> wlan0 IEEE 802.11bgn ESSID:"mjt"
>> Mode:Managed Frequency:2.412 GHz Access Point:
>> 64:70:02:29:D9:30
>> Bit Rate=65 Mb/s Tx-Power=19 dBm
>> Retry short limit:7 RTS thr:off Fragment thr:off
>> Power Management:off
>> Link Quality=58/70 Signal level=-61 dBm
>> Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
>> Tx excessive retries:56355 Invalid misc:472 Missed beacon:0
>>
>> I'll keep trying/testing various cases, in attempt to
>> understand what's going on. For now, I can't provide the
>> requested traces (it wont be very useful, I guess).
>>
>> BTW, are there other things not implemented in brcmsmac?
>> I see the module reminds about power management, what
>> does it mean? Anything else missing?
>
> Well, the wireless twiki has that info [1]. Regarding features the
> important ones that I know are still not there are 40MHz support, and
> power-save. The bcm4313 does not support 40MHz. Community contributions
> added ibss, and ap mode. For P2P and TDLS probably some changes would be
> needed although most of the legwork is done in mac80211.
>
> Regards,
> Arend
>
> [1]
> http://wireless.kernel.org/en/users/Drivers/brcm80211#To_be_done_for_softmac_driver
>
>
>> Thank you!
>>
>> /mjt
>
^ permalink raw reply
* Re: [PATCH] net: can: sja1000: peak_pcmcia.c: Cleaning up missing null-terminate in conjunction with strncpy
From: Stephane Grosjean @ 2014-09-15 8:02 UTC (permalink / raw)
To: Rickard Strandqvist, Wolfgang Grandegger, Marc Kleine-Budde
Cc: Christopher R. Baker, linux-can, netdev, linux-kernel
In-Reply-To: <1410715833-15809-1-git-send-email-rickard_strandqvist@spectrumdigital.se>
Acked-by: Stephane Grosjean <s.grosjean@peak-system.com>
Le 14/09/2014 19:30, Rickard Strandqvist a écrit :
> Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
>
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
> drivers/net/can/sja1000/peak_pcmcia.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/can/sja1000/peak_pcmcia.c b/drivers/net/can/sja1000/peak_pcmcia.c
> index dd56133..fc9f8b01 100644
> --- a/drivers/net/can/sja1000/peak_pcmcia.c
> +++ b/drivers/net/can/sja1000/peak_pcmcia.c
> @@ -487,7 +487,7 @@ static void pcan_free_channels(struct pcan_pccard *card)
> if (!netdev)
> continue;
>
> - strncpy(name, netdev->name, IFNAMSIZ);
> + strlcpy(name, netdev->name, IFNAMSIZ);
>
> unregister_sja1000dev(netdev);
>
--
PEAK-System Technik GmbH, Otto-Roehm-Strasse 69, D-64293 Darmstadt
Geschaeftsleitung: A.Gach/U.Wilhelm,St.Nr.:007/241/13586 FA Darmstadt
HRB-9183 Darmstadt, Ust.IdNr.:DE 202220078, WEE-Reg.-Nr.: DE39305391
Tel.+49 (0)6151-817320 / Fax:+49 (0)6151-817329, info@peak-system.com
--
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox