Re: [PATCH net] sctp: rename sctp_diag.c as diag.c

2018-02-12 Thread Xin Long
On Mon, Feb 12, 2018 at 11:12 PM, David Miller  wrote:
> From: Marcelo Ricardo Leitner 
> Date: Mon, 12 Feb 2018 10:37:04 -0200
>
>> On Mon, Feb 12, 2018 at 06:32:30PM +0800, Xin Long wrote:
>>> Remove sctp_ prefix for diag file, to keep consistent with other
>>> files' names, while at it, also to add file comments for diag.c.
>>
>> Okay but this should be a two-patches series then. The changes made
>> with the rename are hard to find/follow later.
>
> Agreed, the file move should be a separate change from and
> modifications to the file itself.
I will post a two-patch series for this soon.


Re: [PATCH net] sctp: rename sctp_diag.c as diag.c

2018-02-12 Thread David Miller
From: Marcelo Ricardo Leitner 
Date: Mon, 12 Feb 2018 10:37:04 -0200

> On Mon, Feb 12, 2018 at 06:32:30PM +0800, Xin Long wrote:
>> Remove sctp_ prefix for diag file, to keep consistent with other
>> files' names, while at it, also to add file comments for diag.c.
> 
> Okay but this should be a two-patches series then. The changes made
> with the rename are hard to find/follow later.

Agreed, the file move should be a separate change from and
modifications to the file itself.


Re: [PATCH net] sctp: rename sctp_diag.c as diag.c

2018-02-12 Thread Neil Horman
On Mon, Feb 12, 2018 at 06:32:30PM +0800, Xin Long wrote:
> Remove sctp_ prefix for diag file, to keep consistent with other
> files' names, while at it, also to add file comments for diag.c.
> 
> Signed-off-by: Xin Long 
I'm fine with this as a single patch
Acked-by: Neil Horman 

> ---
>  net/sctp/Makefile|   2 +
>  net/sctp/diag.c  | 557 
> +++
>  net/sctp/sctp_diag.c | 526 
>  3 files changed, 559 insertions(+), 526 deletions(-)
>  create mode 100644 net/sctp/diag.c
>  delete mode 100644 net/sctp/sctp_diag.c
> 
> diff --git a/net/sctp/Makefile b/net/sctp/Makefile
> index 6776582..e845e45 100644
> --- a/net/sctp/Makefile
> +++ b/net/sctp/Makefile
> @@ -15,6 +15,8 @@ sctp-y := sm_statetable.o sm_statefuns.o sm_sideeffect.o \
> offload.o stream_sched.o stream_sched_prio.o \
> stream_sched_rr.o stream_interleave.o
>  
> +sctp_diag-y := diag.o
> +
>  sctp-$(CONFIG_SCTP_DBG_OBJCNT) += objcnt.o
>  sctp-$(CONFIG_PROC_FS) += proc.o
>  sctp-$(CONFIG_SYSCTL) += sysctl.o
> diff --git a/net/sctp/diag.c b/net/sctp/diag.c
> new file mode 100644
> index 000..078f01a
> --- /dev/null
> +++ b/net/sctp/diag.c
> @@ -0,0 +1,557 @@
> +/* SCTP kernel implementation
> + * (C) Copyright Red Hat Inc. 2017
> + *
> + * This file is part of the SCTP kernel implementation
> + *
> + * These functions implement sctp diag support.
> + *
> + * This SCTP implementation is free software;
> + * you can redistribute it and/or modify it under the terms of
> + * the GNU General Public License as published by
> + * the Free Software Foundation; either version 2, or (at your option)
> + * any later version.
> + *
> + * This SCTP implementation is distributed in the hope that it
> + * will be useful, but WITHOUT ANY WARRANTY; without even the implied
> + * 
> + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> + * See the GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with GNU CC; see the file COPYING.  If not, see
> + * .
> + *
> + * Please send any bug reports or fixes you make to the
> + * email addresched(es):
> + *lksctp developers 
> + *
> + * Written or modified by:
> + *Xin Long 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static void sctp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
> +void *info);
> +
> +/* define some functions to make asoc/ep fill look clean */
> +static void inet_diag_msg_sctpasoc_fill(struct inet_diag_msg *r,
> + struct sock *sk,
> + struct sctp_association *asoc)
> +{
> + union sctp_addr laddr, paddr;
> + struct dst_entry *dst;
> + struct timer_list *t3_rtx = >peer.primary_path->T3_rtx_timer;
> +
> + laddr = list_entry(asoc->base.bind_addr.address_list.next,
> +struct sctp_sockaddr_entry, list)->a;
> + paddr = asoc->peer.primary_path->ipaddr;
> + dst = asoc->peer.primary_path->dst;
> +
> + r->idiag_family = sk->sk_family;
> + r->id.idiag_sport = htons(asoc->base.bind_addr.port);
> + r->id.idiag_dport = htons(asoc->peer.port);
> + r->id.idiag_if = dst ? dst->dev->ifindex : 0;
> + sock_diag_save_cookie(sk, r->id.idiag_cookie);
> +
> +#if IS_ENABLED(CONFIG_IPV6)
> + if (sk->sk_family == AF_INET6) {
> + *(struct in6_addr *)r->id.idiag_src = laddr.v6.sin6_addr;
> + *(struct in6_addr *)r->id.idiag_dst = paddr.v6.sin6_addr;
> + } else
> +#endif
> + {
> + memset(>id.idiag_src, 0, sizeof(r->id.idiag_src));
> + memset(>id.idiag_dst, 0, sizeof(r->id.idiag_dst));
> +
> + r->id.idiag_src[0] = laddr.v4.sin_addr.s_addr;
> + r->id.idiag_dst[0] = paddr.v4.sin_addr.s_addr;
> + }
> +
> + r->idiag_state = asoc->state;
> + if (timer_pending(t3_rtx)) {
> + r->idiag_timer = SCTP_EVENT_TIMEOUT_T3_RTX;
> + r->idiag_retrans = asoc->rtx_data_chunks;
> + r->idiag_expires = jiffies_to_msecs(t3_rtx->expires - jiffies);
> + } else {
> + r->idiag_timer = 0;
> + r->idiag_retrans = 0;
> + r->idiag_expires = 0;
> + }
> +}
> +
> +static int inet_diag_msg_sctpladdrs_fill(struct sk_buff *skb,
> +  struct list_head *address_list)
> +{
> + struct sctp_sockaddr_entry *laddr;
> + int addrlen = sizeof(struct sockaddr_storage);
> + int addrcnt = 0;
> + struct nlattr *attr;
> + void *info = NULL;
> +
> + list_for_each_entry_rcu(laddr, address_list, list)
> + addrcnt++;
> +
> + attr = nla_reserve(skb, 

Re: [PATCH net] sctp: rename sctp_diag.c as diag.c

2018-02-12 Thread Marcelo Ricardo Leitner
On Mon, Feb 12, 2018 at 06:32:30PM +0800, Xin Long wrote:
> Remove sctp_ prefix for diag file, to keep consistent with other
> files' names, while at it, also to add file comments for diag.c.

Okay but this should be a two-patches series then. The changes made
with the rename are hard to find/follow later.