* [net-next PATCH 0/3] Minor IPv4 routing cleanups
@ 2015-09-28 18:10 Alexander Duyck
2015-09-28 18:10 ` [net-next PATCH 1/3] net/ipv4: Pass proto as u8 instead of u16 in ip_check_mc_rcu Alexander Duyck
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Alexander Duyck @ 2015-09-28 18:10 UTC (permalink / raw)
To: netdev; +Cc: davem
These patches just contain some minor cleanups to address a few minor
issues. The first and the third mostly just improve readability. The
second patch should improve the performance for multicast destination
addresses that do not have a localhost source IP address by avoiding some
unnecessary dereferences.
---
Alexander Duyck (2):
net/ipv4: Pass proto as u8 instead of u16 in ip_check_mc_rcu
net: Swap ordering of tests in ip_route_input_mc
David Ahern (1):
net: Remove martian_source_keep_err goto label
include/linux/igmp.h | 2 +-
net/ipv4/igmp.c | 2 +-
net/ipv4/route.c | 11 ++++-------
3 files changed, 6 insertions(+), 9 deletions(-)
--
^ permalink raw reply [flat|nested] 5+ messages in thread
* [net-next PATCH 1/3] net/ipv4: Pass proto as u8 instead of u16 in ip_check_mc_rcu
2015-09-28 18:10 [net-next PATCH 0/3] Minor IPv4 routing cleanups Alexander Duyck
@ 2015-09-28 18:10 ` Alexander Duyck
2015-09-28 18:10 ` [net-next PATCH 2/3] net: Swap ordering of tests in ip_route_input_mc Alexander Duyck
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Alexander Duyck @ 2015-09-28 18:10 UTC (permalink / raw)
To: netdev; +Cc: davem
This patch updates ip_check_mc_rcu so that protocol is passed as a u8
instead of a u16.
The motivation is just to avoid any unneeded type transitions since some
systems will require an instruction to zero extend a u8 field to a u16.
Also it makes it a bit more readable as to the fact that protocol is a u8
so there are no byte ordering changes needed to pass it.
Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
---
include/linux/igmp.h | 2 +-
net/ipv4/igmp.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index 908429216d9f..9c9de11549a7 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -110,7 +110,7 @@ struct ip_mc_list {
#define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value)
#define IGMPV3_MRC(value) IGMPV3_EXP(0x80, 4, 3, value)
-extern int ip_check_mc_rcu(struct in_device *dev, __be32 mc_addr, __be32 src_addr, u16 proto);
+extern int ip_check_mc_rcu(struct in_device *dev, __be32 mc_addr, __be32 src_addr, u8 proto);
extern int igmp_rcv(struct sk_buff *);
extern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr);
extern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index d38b8b61eaee..de6d4c8ba600 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -2569,7 +2569,7 @@ void ip_mc_drop_socket(struct sock *sk)
}
/* called with rcu_read_lock() */
-int ip_check_mc_rcu(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u16 proto)
+int ip_check_mc_rcu(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u8 proto)
{
struct ip_mc_list *im;
struct ip_mc_list __rcu **mc_hash;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [net-next PATCH 2/3] net: Swap ordering of tests in ip_route_input_mc
2015-09-28 18:10 [net-next PATCH 0/3] Minor IPv4 routing cleanups Alexander Duyck
2015-09-28 18:10 ` [net-next PATCH 1/3] net/ipv4: Pass proto as u8 instead of u16 in ip_check_mc_rcu Alexander Duyck
@ 2015-09-28 18:10 ` Alexander Duyck
2015-09-28 18:10 ` [net-next PATCH 3/3] net: Remove martian_source_keep_err goto label Alexander Duyck
2015-09-29 23:28 ` [net-next PATCH 0/3] Minor IPv4 routing cleanups David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Alexander Duyck @ 2015-09-28 18:10 UTC (permalink / raw)
To: netdev; +Cc: davem
This patch just swaps the ordering of one of the conditional tests in
ip_route_input_mc. Specifically it swaps the testing for the source
address to see if it is loopback, and the test to see if we allow a
loopback source address.
The reason for swapping these two tests is because it is much faster to
test if an address is loopback than it is to dereference several pointers
to get at the net structure to see if the use of loopback is allowed.
Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
---
net/ipv4/route.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 6bab84503cd9..43508c8d08e2 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1487,9 +1487,8 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
skb->protocol != htons(ETH_P_IP))
goto e_inval;
- if (likely(!IN_DEV_ROUTE_LOCALNET(in_dev)))
- if (ipv4_is_loopback(saddr))
- goto e_inval;
+ if (ipv4_is_loopback(saddr) && !IN_DEV_ROUTE_LOCALNET(in_dev))
+ goto e_inval;
if (ipv4_is_zeronet(saddr)) {
if (!ipv4_is_local_multicast(daddr))
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [net-next PATCH 3/3] net: Remove martian_source_keep_err goto label
2015-09-28 18:10 [net-next PATCH 0/3] Minor IPv4 routing cleanups Alexander Duyck
2015-09-28 18:10 ` [net-next PATCH 1/3] net/ipv4: Pass proto as u8 instead of u16 in ip_check_mc_rcu Alexander Duyck
2015-09-28 18:10 ` [net-next PATCH 2/3] net: Swap ordering of tests in ip_route_input_mc Alexander Duyck
@ 2015-09-28 18:10 ` Alexander Duyck
2015-09-29 23:28 ` [net-next PATCH 0/3] Minor IPv4 routing cleanups David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Alexander Duyck @ 2015-09-28 18:10 UTC (permalink / raw)
To: netdev; +Cc: davem
From: David Ahern <dsa@cumulusnetworks.com>
err is initialized to -EINVAL when it is declared. It is not reset until
fib_lookup which is well after the 3 users of the martian_source jump. So
resetting err to -EINVAL at martian_source label is not needed.
Removing that line obviates the need for the martian_source_keep_err label
so delete it.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
---
net/ipv4/route.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 43508c8d08e2..8c84a6664b30 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1759,7 +1759,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
err = fib_validate_source(skb, saddr, daddr, tos,
0, dev, in_dev, &itag);
if (err < 0)
- goto martian_source_keep_err;
+ goto martian_source;
goto local_input;
}
@@ -1781,7 +1781,7 @@ brd_input:
err = fib_validate_source(skb, saddr, 0, tos, 0, dev,
in_dev, &itag);
if (err < 0)
- goto martian_source_keep_err;
+ goto martian_source;
}
flags |= RTCF_BROADCAST;
res.type = RTN_BROADCAST;
@@ -1857,8 +1857,6 @@ e_nobufs:
goto out;
martian_source:
- err = -EINVAL;
-martian_source_keep_err:
ip_handle_martian_source(dev, in_dev, skb, daddr, saddr);
goto out;
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [net-next PATCH 0/3] Minor IPv4 routing cleanups
2015-09-28 18:10 [net-next PATCH 0/3] Minor IPv4 routing cleanups Alexander Duyck
` (2 preceding siblings ...)
2015-09-28 18:10 ` [net-next PATCH 3/3] net: Remove martian_source_keep_err goto label Alexander Duyck
@ 2015-09-29 23:28 ` David Miller
3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2015-09-29 23:28 UTC (permalink / raw)
To: aduyck; +Cc: netdev
From: Alexander Duyck <aduyck@mirantis.com>
Date: Mon, 28 Sep 2015 11:10:25 -0700
> These patches just contain some minor cleanups to address a few minor
> issues. The first and the third mostly just improve readability. The
> second patch should improve the performance for multicast destination
> addresses that do not have a localhost source IP address by avoiding some
> unnecessary dereferences.
Series applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-09-29 23:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-28 18:10 [net-next PATCH 0/3] Minor IPv4 routing cleanups Alexander Duyck
2015-09-28 18:10 ` [net-next PATCH 1/3] net/ipv4: Pass proto as u8 instead of u16 in ip_check_mc_rcu Alexander Duyck
2015-09-28 18:10 ` [net-next PATCH 2/3] net: Swap ordering of tests in ip_route_input_mc Alexander Duyck
2015-09-28 18:10 ` [net-next PATCH 3/3] net: Remove martian_source_keep_err goto label Alexander Duyck
2015-09-29 23:28 ` [net-next PATCH 0/3] Minor IPv4 routing cleanups David Miller
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).