Re: [PATCH net-next 1/5] ipv4: add __ip_queue_xmit() that supports tos param

2018-06-25 Thread Xin Long
On Mon, Jun 25, 2018 at 7:13 PM, Neil Horman  wrote:
> On Mon, Jun 25, 2018 at 04:26:54PM +0900, David Miller wrote:
>> From: Xin Long 
>> Date: Mon, 25 Jun 2018 10:14:33 +0800
>>
>> > +EXPORT_SYMBOL(__ip_queue_xmit);
>> > +
>> > +int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
>> > +{
>> > +   return __ip_queue_xmit(sk, skb, fl, inet_sk(sk)->tos);
>> > +}
>> >  EXPORT_SYMBOL(ip_queue_xmit);
>>
>> Maybe better to only export __ip_queue_xmit() and make ip_queue_xmit() an
>> inline function in net/ip.h?
>>
> I concur.  No need to export both here
>
will do that.


Re: [PATCH net-next 1/5] ipv4: add __ip_queue_xmit() that supports tos param

2018-06-25 Thread Neil Horman
On Mon, Jun 25, 2018 at 04:26:54PM +0900, David Miller wrote:
> From: Xin Long 
> Date: Mon, 25 Jun 2018 10:14:33 +0800
> 
> > +EXPORT_SYMBOL(__ip_queue_xmit);
> > +
> > +int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
> > +{
> > +   return __ip_queue_xmit(sk, skb, fl, inet_sk(sk)->tos);
> > +}
> >  EXPORT_SYMBOL(ip_queue_xmit);
> 
> Maybe better to only export __ip_queue_xmit() and make ip_queue_xmit() an
> inline function in net/ip.h?
> 
I concur.  No need to export both here

Neil




Re: [PATCH net-next 1/5] ipv4: add __ip_queue_xmit() that supports tos param

2018-06-25 Thread David Miller
From: Xin Long 
Date: Mon, 25 Jun 2018 10:14:33 +0800

> +EXPORT_SYMBOL(__ip_queue_xmit);
> +
> +int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
> +{
> + return __ip_queue_xmit(sk, skb, fl, inet_sk(sk)->tos);
> +}
>  EXPORT_SYMBOL(ip_queue_xmit);

Maybe better to only export __ip_queue_xmit() and make ip_queue_xmit() an
inline function in net/ip.h?


[PATCH net-next 1/5] ipv4: add __ip_queue_xmit() that supports tos param

2018-06-24 Thread Xin Long
This patch introduces __ip_queue_xmit(), through which the callers
can pass tos param into it without having to set inet->tos. For
ipv6, ip6_xmit() already allows passing tclass parameter.

It's needed when some transport protocol doesn't use inet->tos,
like sctp's per transport dscp, which will be added in next patch.

Signed-off-by: Xin Long 
---
 include/net/ip.h |  2 ++
 net/ipv4/ip_output.c | 13 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/net/ip.h b/include/net/ip.h
index 0d2281b..ca05b77 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -148,6 +148,8 @@ void ip_send_check(struct iphdr *ip);
 int __ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb);
 int ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb);
 
+int __ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
+   __u8 tos);
 int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl);
 void ip_init(void);
 int ip_append_data(struct sock *sk, struct flowi4 *fl4,
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index b3308e9..107d37f 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -423,7 +423,8 @@ static void ip_copy_addrs(struct iphdr *iph, const struct 
flowi4 *fl4)
 }
 
 /* Note: skb->sk can be different from sk, in case of tunnels */
-int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
+int __ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
+   __u8 tos)
 {
struct inet_sock *inet = inet_sk(sk);
struct net *net = sock_net(sk);
@@ -462,7 +463,7 @@ int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, 
struct flowi *fl)
   inet->inet_dport,
   inet->inet_sport,
   sk->sk_protocol,
-  RT_CONN_FLAGS(sk),
+  RT_CONN_FLAGS_TOS(sk, tos),
   sk->sk_bound_dev_if);
if (IS_ERR(rt))
goto no_route;
@@ -478,7 +479,7 @@ int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, 
struct flowi *fl)
skb_push(skb, sizeof(struct iphdr) + (inet_opt ? inet_opt->opt.optlen : 
0));
skb_reset_network_header(skb);
iph = ip_hdr(skb);
-   *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff));
+   *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (tos & 0xff));
if (ip_dont_fragment(sk, >dst) && !skb->ignore_df)
iph->frag_off = htons(IP_DF);
else
@@ -511,6 +512,12 @@ int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, 
struct flowi *fl)
kfree_skb(skb);
return -EHOSTUNREACH;
 }
+EXPORT_SYMBOL(__ip_queue_xmit);
+
+int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
+{
+   return __ip_queue_xmit(sk, skb, fl, inet_sk(sk)->tos);
+}
 EXPORT_SYMBOL(ip_queue_xmit);
 
 static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
-- 
2.1.0