* [PATCH net-next 0/5] net: Add saddr op to l3mdev and vrf
@ 2015-10-01 15:27 David Ahern
2015-10-01 15:27 ` [PATCH net-next 1/5] net: Rename FLOWI_FLAG_VRFSRC to FLOWI_FLAG_L3MDEV_SRC David Ahern
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: David Ahern @ 2015-10-01 15:27 UTC (permalink / raw)
To: netdev; +Cc: dsahern, David Ahern
First 2 patches are re-sends of patches that got lost in the ethosphere
Tuesday; they were part of the first round of l3mdev conversions.
Next 3 handle the source address lookup for raw and datagram sockets
bound to a VRF device.
The conversion to the get_saddr op also fixes locally originated TCP
packets showing up at the VRF device. The use of the FLOWI_FLAG_L3MDEV_SRC
flag in ip_route_connect_init was causing locally generated packets
to skip the VRF device.
David Ahern (5):
net: Rename FLOWI_FLAG_VRFSRC to FLOWI_FLAG_L3MDEV_SRC
net: Add netif_is_l3_slave
net: Refactor path selection in __ip_route_output_key
net: Add source address lookup op for VRF
net: Add l3mdev saddr lookup to raw_sendmsg
drivers/net/vrf.c | 47 ++++++++++++++++++++++++++++++++++++++++-------
include/linux/netdevice.h | 7 +++++++
include/net/flow.h | 2 +-
include/net/ip_fib.h | 2 ++
include/net/l3mdev.h | 27 +++++++++++++++++++++++++++
include/net/route.h | 7 ++++---
net/ipv4/fib_semantics.c | 18 ++++++++++++++++++
net/ipv4/raw.c | 8 ++++++--
net/ipv4/route.c | 13 +------------
net/ipv4/udp.c | 22 +++-------------------
net/l3mdev/l3mdev.c | 8 ++++----
11 files changed, 113 insertions(+), 48 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net-next 1/5] net: Rename FLOWI_FLAG_VRFSRC to FLOWI_FLAG_L3MDEV_SRC
2015-10-01 15:27 [PATCH net-next 0/5] net: Add saddr op to l3mdev and vrf David Ahern
@ 2015-10-01 15:27 ` David Ahern
2015-10-01 15:27 ` [PATCH net-next 2/5] net: Add netif_is_l3_slave David Ahern
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: David Ahern @ 2015-10-01 15:27 UTC (permalink / raw)
To: netdev; +Cc: dsahern, David Ahern
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
drivers/net/vrf.c | 4 ++--
include/net/flow.h | 2 +-
include/net/route.h | 2 +-
net/ipv4/udp.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 64f2ab663ffe..f2f9c7091130 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -208,7 +208,7 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
.flowi4_oif = vrf_dev->ifindex,
.flowi4_iif = LOOPBACK_IFINDEX,
.flowi4_tos = RT_TOS(ip4h->tos),
- .flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_VRFSRC |
+ .flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_L3MDEV_SRC |
FLOWI_FLAG_SKIP_NH_OIF,
.daddr = ip4h->daddr,
};
@@ -545,7 +545,7 @@ static struct rtable *vrf_get_rtable(const struct net_device *dev,
{
struct rtable *rth = NULL;
- if (!(fl4->flowi4_flags & FLOWI_FLAG_VRFSRC)) {
+ if (!(fl4->flowi4_flags & FLOWI_FLAG_L3MDEV_SRC)) {
struct net_vrf *vrf = netdev_priv(dev);
rth = vrf->rth;
diff --git a/include/net/flow.h b/include/net/flow.h
index 9b85db85f13c..83969eebebf3 100644
--- a/include/net/flow.h
+++ b/include/net/flow.h
@@ -34,7 +34,7 @@ struct flowi_common {
__u8 flowic_flags;
#define FLOWI_FLAG_ANYSRC 0x01
#define FLOWI_FLAG_KNOWN_NH 0x02
-#define FLOWI_FLAG_VRFSRC 0x04
+#define FLOWI_FLAG_L3MDEV_SRC 0x04
#define FLOWI_FLAG_SKIP_NH_OIF 0x08
__u32 flowic_secid;
struct flowi_tunnel flowic_tun_key;
diff --git a/include/net/route.h b/include/net/route.h
index e211dc167db1..7929c9c33587 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -258,7 +258,7 @@ static inline void ip_route_connect_init(struct flowi4 *fl4, __be32 dst, __be32
flow_flags |= FLOWI_FLAG_ANYSRC;
if (netif_index_is_l3_master(sock_net(sk), oif))
- flow_flags |= FLOWI_FLAG_VRFSRC | FLOWI_FLAG_SKIP_NH_OIF;
+ flow_flags |= FLOWI_FLAG_L3MDEV_SRC | FLOWI_FLAG_SKIP_NH_OIF;
flowi4_init_output(fl4, oif, sk->sk_mark, tos, RT_SCOPE_UNIVERSE,
protocol, flow_flags, dst, src, dport, sport);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 156ba75b6000..b2882cfd3136 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1024,7 +1024,7 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
if (netif_index_is_l3_master(net, ipc.oif)) {
flowi4_init_output(fl4, ipc.oif, sk->sk_mark, tos,
RT_SCOPE_UNIVERSE, sk->sk_protocol,
- (flow_flags | FLOWI_FLAG_VRFSRC |
+ (flow_flags | FLOWI_FLAG_L3MDEV_SRC |
FLOWI_FLAG_SKIP_NH_OIF),
faddr, saddr, dport,
inet->inet_sport);
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next 2/5] net: Add netif_is_l3_slave
2015-10-01 15:27 [PATCH net-next 0/5] net: Add saddr op to l3mdev and vrf David Ahern
2015-10-01 15:27 ` [PATCH net-next 1/5] net: Rename FLOWI_FLAG_VRFSRC to FLOWI_FLAG_L3MDEV_SRC David Ahern
@ 2015-10-01 15:27 ` David Ahern
2015-10-05 14:44 ` David Ahern
2015-10-01 15:27 ` [PATCH net-next 3/5] net: Refactor path selection in __ip_route_output_key David Ahern
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: David Ahern @ 2015-10-01 15:27 UTC (permalink / raw)
To: netdev; +Cc: dsahern, David Ahern
IPv6 addrconf keys off of IFF_SLAVE so can not use it for L3 slave.
Add a new private flag and add netif_is_l3_slave function for checking
it.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
drivers/net/vrf.c | 8 +++-----
include/linux/netdevice.h | 7 +++++++
net/l3mdev/l3mdev.c | 8 ++++----
3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index f2f9c7091130..277a8e0a6a4f 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -39,8 +39,6 @@
#define DRV_NAME "vrf"
#define DRV_VERSION "1.0"
-#define vrf_is_slave(dev) ((dev)->flags & IFF_SLAVE)
-
#define vrf_master_get_rcu(dev) \
((struct net_device *)rcu_dereference(dev->rx_handler_data))
@@ -433,7 +431,7 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev)
if (ret < 0)
goto out_unregister;
- port_dev->flags |= IFF_SLAVE;
+ port_dev->priv_flags |= IFF_L3MDEV_SLAVE;
__vrf_insert_slave(queue, slave);
cycle_netdev(port_dev);
@@ -448,7 +446,7 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev)
static int vrf_add_slave(struct net_device *dev, struct net_device *port_dev)
{
- if (netif_is_l3_master(port_dev) || vrf_is_slave(port_dev))
+ if (netif_is_l3_master(port_dev) || netif_is_l3_slave(port_dev))
return -EINVAL;
return do_vrf_add_slave(dev, port_dev);
@@ -462,7 +460,7 @@ static int do_vrf_del_slave(struct net_device *dev, struct net_device *port_dev)
struct slave *slave;
netdev_upper_dev_unlink(port_dev, dev);
- port_dev->flags &= ~IFF_SLAVE;
+ port_dev->priv_flags &= ~IFF_L3MDEV_SLAVE;
netdev_rx_handler_unregister(port_dev);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index b9450784ae06..b3374402c1ea 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1261,6 +1261,7 @@ struct net_device_ops {
* @IFF_L3MDEV_MASTER: device is an L3 master device
* @IFF_NO_QUEUE: device can run without qdisc attached
* @IFF_OPENVSWITCH: device is a Open vSwitch master
+ * @IFF_L3MDEV_SLAVE: device is enslaved to an L3 master device
*/
enum netdev_priv_flags {
IFF_802_1Q_VLAN = 1<<0,
@@ -1286,6 +1287,7 @@ enum netdev_priv_flags {
IFF_L3MDEV_MASTER = 1<<20,
IFF_NO_QUEUE = 1<<21,
IFF_OPENVSWITCH = 1<<22,
+ IFF_L3MDEV_SLAVE = 1<<23,
};
#define IFF_802_1Q_VLAN IFF_802_1Q_VLAN
@@ -3830,6 +3832,11 @@ static inline bool netif_is_l3_master(const struct net_device *dev)
return dev->priv_flags & IFF_L3MDEV_MASTER;
}
+static inline bool netif_is_l3_slave(const struct net_device *dev)
+{
+ return dev->priv_flags & IFF_L3MDEV_SLAVE;
+}
+
static inline bool netif_is_bridge_master(const struct net_device *dev)
{
return dev->priv_flags & IFF_EBRIDGE;
diff --git a/net/l3mdev/l3mdev.c b/net/l3mdev/l3mdev.c
index ddf75ad41713..8e5ead366e7f 100644
--- a/net/l3mdev/l3mdev.c
+++ b/net/l3mdev/l3mdev.c
@@ -26,11 +26,11 @@ int l3mdev_master_ifindex_rcu(struct net_device *dev)
if (netif_is_l3_master(dev)) {
ifindex = dev->ifindex;
- } else if (dev->flags & IFF_SLAVE) {
+ } else if (netif_is_l3_slave(dev)) {
struct net_device *master;
master = netdev_master_upper_dev_get_rcu(dev);
- if (master && netif_is_l3_master(master))
+ if (master)
ifindex = master->ifindex;
}
@@ -54,7 +54,7 @@ u32 l3mdev_fib_table_rcu(const struct net_device *dev)
if (netif_is_l3_master(dev)) {
if (dev->l3mdev_ops->l3mdev_fib_table)
tb_id = dev->l3mdev_ops->l3mdev_fib_table(dev);
- } else if (dev->flags & IFF_SLAVE) {
+ } else if (netif_is_l3_slave(dev)) {
/* Users of netdev_master_upper_dev_get_rcu need non-const,
* but current inet_*type functions take a const
*/
@@ -62,7 +62,7 @@ u32 l3mdev_fib_table_rcu(const struct net_device *dev)
const struct net_device *master;
master = netdev_master_upper_dev_get_rcu(_dev);
- if (master && netif_is_l3_master(master) &&
+ if (master &&
master->l3mdev_ops->l3mdev_fib_table)
tb_id = master->l3mdev_ops->l3mdev_fib_table(master);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next 3/5] net: Refactor path selection in __ip_route_output_key
2015-10-01 15:27 [PATCH net-next 0/5] net: Add saddr op to l3mdev and vrf David Ahern
2015-10-01 15:27 ` [PATCH net-next 1/5] net: Rename FLOWI_FLAG_VRFSRC to FLOWI_FLAG_L3MDEV_SRC David Ahern
2015-10-01 15:27 ` [PATCH net-next 2/5] net: Add netif_is_l3_slave David Ahern
@ 2015-10-01 15:27 ` David Ahern
2015-10-02 6:20 ` kbuild test robot
2015-10-01 15:27 ` [PATCH net-next 4/5] net: Add source address lookup op for VRF David Ahern
2015-10-01 15:27 ` [PATCH net-next 5/5] net: Add l3mdev saddr lookup to raw_sendmsg David Ahern
4 siblings, 1 reply; 10+ messages in thread
From: David Ahern @ 2015-10-01 15:27 UTC (permalink / raw)
To: netdev; +Cc: dsahern, David Ahern
VRF device needs same path selection following lookup to set source
address. Rather than duplicating code, move existing code into a
function that is exported to modules.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
include/net/ip_fib.h | 2 ++
net/ipv4/fib_semantics.c | 18 ++++++++++++++++++
net/ipv4/route.c | 13 +------------
3 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 727d6e9a9685..30469855edf5 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -321,6 +321,8 @@ int fib_sync_down_dev(struct net_device *dev, unsigned long event);
int fib_sync_down_addr(struct net *net, __be32 local);
int fib_sync_up(struct net_device *dev, unsigned int nh_flags);
void fib_select_multipath(struct fib_result *res);
+void fib_select_path(struct net *net, struct fib_result *res,
+ struct flowi4 *fl4);
/* Exported by fib_trie.c */
void fib_trie_init(void);
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 064bd3caaa4f..facba7ed27de 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1547,3 +1547,21 @@ void fib_select_multipath(struct fib_result *res)
spin_unlock_bh(&fib_multipath_lock);
}
#endif
+
+void fib_select_path(struct net *net, struct fib_result *res,
+ struct flowi4 *fl4)
+{
+#ifdef CONFIG_IP_ROUTE_MULTIPATH
+ if (res->fi->fib_nhs > 1 && fl4->flowi4_oif == 0)
+ fib_select_multipath(res);
+ else
+#endif
+ if (!res->prefixlen &&
+ res->table->tb_num_default > 1 &&
+ res->type == RTN_UNICAST && !fl4->flowi4_oif)
+ fib_select_default(fl4, res);
+
+ if (!fl4->saddr)
+ fl4->saddr = FIB_RES_PREFSRC(net, *res);
+}
+EXPORT_SYMBOL_GPL(fib_select_path);
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 1441de1550e6..747042504967 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2187,18 +2187,7 @@ struct rtable *__ip_route_output_key(struct net *net, struct flowi4 *fl4)
goto make_route;
}
-#ifdef CONFIG_IP_ROUTE_MULTIPATH
- if (res.fi->fib_nhs > 1 && fl4->flowi4_oif == 0)
- fib_select_multipath(&res);
- else
-#endif
- if (!res.prefixlen &&
- res.table->tb_num_default > 1 &&
- res.type == RTN_UNICAST && !fl4->flowi4_oif)
- fib_select_default(fl4, &res);
-
- if (!fl4->saddr)
- fl4->saddr = FIB_RES_PREFSRC(net, res);
+ fib_select_path(net, &res, fl4);
dev_out = FIB_RES_DEV(res);
fl4->flowi4_oif = dev_out->ifindex;
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next 4/5] net: Add source address lookup op for VRF
2015-10-01 15:27 [PATCH net-next 0/5] net: Add saddr op to l3mdev and vrf David Ahern
` (2 preceding siblings ...)
2015-10-01 15:27 ` [PATCH net-next 3/5] net: Refactor path selection in __ip_route_output_key David Ahern
@ 2015-10-01 15:27 ` David Ahern
2015-10-01 15:27 ` [PATCH net-next 5/5] net: Add l3mdev saddr lookup to raw_sendmsg David Ahern
4 siblings, 0 replies; 10+ messages in thread
From: David Ahern @ 2015-10-01 15:27 UTC (permalink / raw)
To: netdev; +Cc: dsahern, David Ahern
Add operation to l3mdev to lookup source address for a given flow.
Add support for the operation to VRF driver and convert existing
IPv4 hooks to use the new lookup.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
drivers/net/vrf.c | 35 +++++++++++++++++++++++++++++++++++
include/net/l3mdev.h | 27 +++++++++++++++++++++++++++
include/net/route.h | 7 ++++---
net/ipv4/udp.c | 22 +++-------------------
4 files changed, 69 insertions(+), 22 deletions(-)
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 277a8e0a6a4f..94881260fcfd 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -36,6 +36,9 @@
#include <net/addrconf.h>
#include <net/l3mdev.h>
+#define RT_FL_TOS(oldflp4) \
+ ((oldflp4)->flowi4_tos & (IPTOS_RT_MASK | RTO_ONLINK))
+
#define DRV_NAME "vrf"
#define DRV_VERSION "1.0"
@@ -553,9 +556,41 @@ static struct rtable *vrf_get_rtable(const struct net_device *dev,
return rth;
}
+/* called under rcu_read_lock */
+static void vrf_get_saddr(struct net_device *dev, struct flowi4 *fl4)
+{
+ struct fib_result res = { .tclassid = 0 };
+ struct net *net = dev_net(dev);
+ u32 orig_tos = fl4->flowi4_tos;
+ u8 flags = fl4->flowi4_flags;
+ u8 scope = fl4->flowi4_scope;
+ u8 tos = RT_FL_TOS(fl4);
+
+ if (unlikely(!fl4->daddr))
+ return;
+
+ fl4->flowi4_flags |= FLOWI_FLAG_SKIP_NH_OIF;
+ fl4->flowi4_iif = LOOPBACK_IFINDEX;
+ fl4->flowi4_tos = tos & IPTOS_RT_MASK;
+ fl4->flowi4_scope = ((tos & RTO_ONLINK) ?
+ RT_SCOPE_LINK : RT_SCOPE_UNIVERSE);
+
+ if (!fib_lookup(net, fl4, &res, 0)) {
+ if (res.type == RTN_LOCAL)
+ fl4->saddr = res.fi->fib_prefsrc ? : fl4->daddr;
+ else
+ fib_select_path(net, &res, fl4);
+ }
+
+ fl4->flowi4_flags = flags;
+ fl4->flowi4_tos = orig_tos;
+ fl4->flowi4_scope = scope;
+}
+
static const struct l3mdev_ops vrf_l3mdev_ops = {
.l3mdev_fib_table = vrf_fib_table,
.l3mdev_get_rtable = vrf_get_rtable,
+ .l3mdev_get_saddr = vrf_get_saddr,
};
static void vrf_get_drvinfo(struct net_device *dev,
diff --git a/include/net/l3mdev.h b/include/net/l3mdev.h
index 87cee05a0a17..44a19a171104 100644
--- a/include/net/l3mdev.h
+++ b/include/net/l3mdev.h
@@ -17,12 +17,16 @@
* @l3mdev_fib_table: Get FIB table id to use for lookups
*
* @l3mdev_get_rtable: Get cached IPv4 rtable (dst_entry) for device
+ *
+ * @l3mdev_get_saddr: Get source address for a flow
*/
struct l3mdev_ops {
u32 (*l3mdev_fib_table)(const struct net_device *dev);
struct rtable * (*l3mdev_get_rtable)(const struct net_device *dev,
const struct flowi4 *fl4);
+ void (*l3mdev_get_saddr)(struct net_device *dev,
+ struct flowi4 *fl4);
};
#ifdef CONFIG_NET_L3_MASTER_DEV
@@ -100,6 +104,25 @@ static inline bool netif_index_is_l3_master(struct net *net, int ifindex)
return rc;
}
+static inline void l3mdev_get_saddr(struct net *net, int ifindex,
+ struct flowi4 *fl4)
+{
+ struct net_device *dev;
+
+ if (ifindex) {
+
+ rcu_read_lock();
+
+ dev = dev_get_by_index_rcu(net, ifindex);
+ if (dev && netif_is_l3_master(dev) &&
+ dev->l3mdev_ops->l3mdev_get_saddr) {
+ dev->l3mdev_ops->l3mdev_get_saddr(dev, fl4);
+ }
+
+ rcu_read_unlock();
+ }
+}
+
#else
static inline int l3mdev_master_ifindex_rcu(struct net_device *dev)
@@ -144,6 +167,10 @@ static inline bool netif_index_is_l3_master(struct net *net, int ifindex)
return false;
}
+static inline void l3mdev_get_saddr(struct net *net, int ifindex,
+ struct flowi4 *fl4)
+{
+}
#endif
#endif /* _NET_L3MDEV_H_ */
diff --git a/include/net/route.h b/include/net/route.h
index 7929c9c33587..a7cb5d02f0f9 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -257,9 +257,6 @@ static inline void ip_route_connect_init(struct flowi4 *fl4, __be32 dst, __be32
if (inet_sk(sk)->transparent)
flow_flags |= FLOWI_FLAG_ANYSRC;
- if (netif_index_is_l3_master(sock_net(sk), oif))
- flow_flags |= FLOWI_FLAG_L3MDEV_SRC | FLOWI_FLAG_SKIP_NH_OIF;
-
flowi4_init_output(fl4, oif, sk->sk_mark, tos, RT_SCOPE_UNIVERSE,
protocol, flow_flags, dst, src, dport, sport);
}
@@ -276,6 +273,10 @@ static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
sport, dport, sk);
+ if (!src && oif) {
+ l3mdev_get_saddr(net, oif, fl4);
+ src = fl4->saddr;
+ }
if (!dst || !src) {
rt = __ip_route_output_key(net, fl4);
if (IS_ERR(rt))
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index b2882cfd3136..e1fc129099ea 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1017,30 +1017,14 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
fl4 = &fl4_stack;
- /* unconnected socket. If output device is enslaved to a VRF
- * device lookup source address from VRF table. This mimics
- * behavior of ip_route_connect{_init}.
- */
- if (netif_index_is_l3_master(net, ipc.oif)) {
- flowi4_init_output(fl4, ipc.oif, sk->sk_mark, tos,
- RT_SCOPE_UNIVERSE, sk->sk_protocol,
- (flow_flags | FLOWI_FLAG_L3MDEV_SRC |
- FLOWI_FLAG_SKIP_NH_OIF),
- faddr, saddr, dport,
- inet->inet_sport);
-
- rt = ip_route_output_flow(net, fl4, sk);
- if (!IS_ERR(rt)) {
- saddr = fl4->saddr;
- ip_rt_put(rt);
- }
- }
-
flowi4_init_output(fl4, ipc.oif, sk->sk_mark, tos,
RT_SCOPE_UNIVERSE, sk->sk_protocol,
flow_flags,
faddr, saddr, dport, inet->inet_sport);
+ if (!saddr && ipc.oif)
+ l3mdev_get_saddr(net, ipc.oif, fl4);
+
security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
rt = ip_route_output_flow(net, fl4, sk);
if (IS_ERR(rt)) {
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next 5/5] net: Add l3mdev saddr lookup to raw_sendmsg
2015-10-01 15:27 [PATCH net-next 0/5] net: Add saddr op to l3mdev and vrf David Ahern
` (3 preceding siblings ...)
2015-10-01 15:27 ` [PATCH net-next 4/5] net: Add source address lookup op for VRF David Ahern
@ 2015-10-01 15:27 ` David Ahern
4 siblings, 0 replies; 10+ messages in thread
From: David Ahern @ 2015-10-01 15:27 UTC (permalink / raw)
To: netdev; +Cc: dsahern, David Ahern
ping originated on box through a VRF device is showing up in tcpdump
without a source address:
$ tcpdump -n -i vrf-blue
08:58:33.311303 IP 0.0.0.0 > 10.2.2.254: ICMP echo request, id 2834, seq 1, length 64
08:58:33.311562 IP 10.2.2.254 > 10.2.2.2: ICMP echo reply, id 2834, seq 1, length 64
Add the call to l3mdev_get_saddr to raw_sendmsg.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
net/ipv4/raw.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 28ef8a913130..09a07e8b2f35 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -484,6 +484,7 @@ static int raw_getfrag(void *from, char *to, int offset, int len, int odd,
static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
{
struct inet_sock *inet = inet_sk(sk);
+ struct net *net = sock_net(sk);
struct ipcm_cookie ipc;
struct rtable *rt = NULL;
struct flowi4 fl4;
@@ -543,7 +544,7 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
ipc.oif = sk->sk_bound_dev_if;
if (msg->msg_controllen) {
- err = ip_cmsg_send(sock_net(sk), msg, &ipc, false);
+ err = ip_cmsg_send(net, msg, &ipc, false);
if (err)
goto out;
if (ipc.opt)
@@ -598,6 +599,9 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
(inet->hdrincl ? FLOWI_FLAG_KNOWN_NH : 0),
daddr, saddr, 0, 0);
+ if (!saddr && ipc.oif)
+ l3mdev_get_saddr(net, ipc.oif, &fl4);
+
if (!inet->hdrincl) {
rfv.msg = msg;
rfv.hlen = 0;
@@ -608,7 +612,7 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
}
security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
- rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
+ rt = ip_route_output_flow(net, &fl4, sk);
if (IS_ERR(rt)) {
err = PTR_ERR(rt);
rt = NULL;
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 3/5] net: Refactor path selection in __ip_route_output_key
2015-10-01 15:27 ` [PATCH net-next 3/5] net: Refactor path selection in __ip_route_output_key David Ahern
@ 2015-10-02 6:20 ` kbuild test robot
2015-10-05 13:38 ` David Miller
0 siblings, 1 reply; 10+ messages in thread
From: kbuild test robot @ 2015-10-02 6:20 UTC (permalink / raw)
To: David Ahern; +Cc: kbuild-all, netdev, dsahern, David Ahern
[-- Attachment #1: Type: text/plain, Size: 719 bytes --]
Hi David,
[auto build test results on next-20151001 -- if it's inappropriate base, please ignore]
config: mips-nlm_xlp_defconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=mips
All warnings (new ones prefixed by >>):
>> mips-linux-gnu-ld: net/ipv4/.tmp_fib_semantics.o: warning: Inconsistent ISA between e_flags and .MIPS.abiflags
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 17816 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 3/5] net: Refactor path selection in __ip_route_output_key
2015-10-02 6:20 ` kbuild test robot
@ 2015-10-05 13:38 ` David Miller
2015-10-05 14:08 ` David Ahern
0 siblings, 1 reply; 10+ messages in thread
From: David Miller @ 2015-10-05 13:38 UTC (permalink / raw)
To: lkp; +Cc: dsa, kbuild-all, netdev, dsahern
From: kbuild test robot <lkp@intel.com>
Date: Fri, 2 Oct 2015 14:20:30 +0800
> Hi David,
>
> [auto build test results on next-20151001 -- if it's inappropriate base, please ignore]
>
> config: mips-nlm_xlp_defconfig (attached as .config)
> reproduce:
> wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=mips
>
> All warnings (new ones prefixed by >>):
>
>>> mips-linux-gnu-ld: net/ipv4/.tmp_fib_semantics.o: warning: Inconsistent ISA between e_flags and .MIPS.abiflags
Frankly this looks like a build infrastructure or tools bug to me.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 3/5] net: Refactor path selection in __ip_route_output_key
2015-10-05 13:38 ` David Miller
@ 2015-10-05 14:08 ` David Ahern
0 siblings, 0 replies; 10+ messages in thread
From: David Ahern @ 2015-10-05 14:08 UTC (permalink / raw)
To: David Miller, lkp; +Cc: kbuild-all, netdev, dsahern, linux-mips
On 10/5/15 7:38 AM, David Miller wrote:
> From: kbuild test robot <lkp@intel.com>
> Date: Fri, 2 Oct 2015 14:20:30 +0800
>
>> Hi David,
>>
>> [auto build test results on next-20151001 -- if it's inappropriate base, please ignore]
>>
>> config: mips-nlm_xlp_defconfig (attached as .config)
>> reproduce:
>> wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>> chmod +x ~/bin/make.cross
>> # save the attached .config to linux build tree
>> make.cross ARCH=mips
>>
>> All warnings (new ones prefixed by >>):
>>
>>>> mips-linux-gnu-ld: net/ipv4/.tmp_fib_semantics.o: warning: Inconsistent ISA between e_flags and .MIPS.abiflags
>
> Frankly this looks like a build infrastructure or tools bug to me.
>
That's pretty much what I got back from Joshua on the linux-mips mailing
list when I inquired about why a code move generates the warning:
"Dunno if your patch generated the message per-say, but it seems some
platforms in the MIPS tree cause this message to appear. I.e., IP27 or
IP32 builds (or IP30 out-of-tree) don't emit this error, but building
IP28 systems in-tree will cause it to appear quite a bit.
The message itself, I believe is complaining that the stated CPU ISA
(mips1 ... mips4, mips32r2, r10000, etc) in one of the sections
(e.g.,.MIPS.abiflags) doesn't match the equivalent ISA value in the
other section (e.g., e_flags). I haven't seen any harmful side effects
of it myself. Seems to be more of a warning than anything else, and as
long as the ISA matches a supported CPU (e.g., r10000 is compatible with
mips4), it can be ignored. It does clutter up the build, though."
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 2/5] net: Add netif_is_l3_slave
2015-10-01 15:27 ` [PATCH net-next 2/5] net: Add netif_is_l3_slave David Ahern
@ 2015-10-05 14:44 ` David Ahern
0 siblings, 0 replies; 10+ messages in thread
From: David Ahern @ 2015-10-05 14:44 UTC (permalink / raw)
To: netdev; +Cc: David Miller
On 10/1/15 9:27 AM, David Ahern wrote:
> IPv6 addrconf keys off of IFF_SLAVE so can not use it for L3 slave.
> Add a new private flag and add netif_is_l3_slave function for checking
> it.
After pulling in Cong's patch to address the warning on device remove I
need to respin this one.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-10-05 14:44 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-01 15:27 [PATCH net-next 0/5] net: Add saddr op to l3mdev and vrf David Ahern
2015-10-01 15:27 ` [PATCH net-next 1/5] net: Rename FLOWI_FLAG_VRFSRC to FLOWI_FLAG_L3MDEV_SRC David Ahern
2015-10-01 15:27 ` [PATCH net-next 2/5] net: Add netif_is_l3_slave David Ahern
2015-10-05 14:44 ` David Ahern
2015-10-01 15:27 ` [PATCH net-next 3/5] net: Refactor path selection in __ip_route_output_key David Ahern
2015-10-02 6:20 ` kbuild test robot
2015-10-05 13:38 ` David Miller
2015-10-05 14:08 ` David Ahern
2015-10-01 15:27 ` [PATCH net-next 4/5] net: Add source address lookup op for VRF David Ahern
2015-10-01 15:27 ` [PATCH net-next 5/5] net: Add l3mdev saddr lookup to raw_sendmsg David Ahern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).