[PATCH 7/8] netlink: add a basic socket diag parser of AF_SMC messages
Dmitry V. Levin
ldv at altlinux.org
Wed Jun 14 10:20:55 UTC 2017
On Wed, Jun 14, 2017 at 04:51:13PM +0800, JingPiao Chen wrote:
> On Tue, Jun 13, 2017 at 11:47:45PM +0300, Dmitry V. Levin wrote:
> > On Tue, Jun 13, 2017 at 10:13:24PM +0800, JingPiao Chen wrote:
> [...]
> > > +#ifdef AF_SMC
> > > +static bool
> > > +decode_smc_diag_req(struct tcb *const tcp,
> > > + const struct nlmsghdr *const nlmsghdr,
> > > + const kernel_ulong_t addr,
> > > + const kernel_ulong_t len)
> > > +{
> > > + struct smc_diag_req req;
> > > +
> > > + if (len < sizeof(req) || umove(tcp, addr, &req))
> > > + return false;
> > > +
> > > + tprints("{diag_family=");
> > > + printxval(addrfams, req.diag_family, "AF_???");
> > > + tprints(", diag_ext=");
> > > + printflags(smc_diag_extended_flags, req.diag_ext,
> > > + "1<<(SMC_DIAG_\?\?\?-1)");
> > > + tprints(", id=");
> > > + /*
> > > + * AF_SMC protocol family socket handler
> > > + * keeping the AF_INET sock address.
> > > + */
> > > + print_inet_diag_sockid(&req.id, AF_INET);
> >
> > Is it correct? Does the kernel treat smc_diag_req.id as AF_INET,
> AF_INET6,
> > or something else?
> >
>
> The comment exist in net/smc/af_smc.c: 4
> * AF_SMC protocol family socket handler keeping the AF_INET sock address
> type
> * applies to SOCK_STREAM sockets only
>
> net/smc/smc_diag.c:
> static void smc_diag_msg_common_fill(struct smc_diag_msg *r, struct sock
> *sk)
> {
> struct smc_sock *smc = smc_sk(sk);
>
> r->diag_family = sk->sk_family;
> if (!smc->clcsock)
> return;
> r->id.idiag_sport = htons(smc->clcsock->sk->sk_num);
> r->id.idiag_dport = smc->clcsock->sk->sk_dport;
> r->id.idiag_if = smc->clcsock->sk->sk_bound_dev_if;
> sock_diag_save_cookie(sk, r->id.idiag_cookie);
> memset(&r->id.idiag_src, 0, sizeof(r->id.idiag_src));
> memset(&r->id.idiag_dst, 0, sizeof(r->id.idiag_dst));
> r->id.idiag_src[0] = smc->clcsock->sk->sk_rcv_saddr;
> r->id.idiag_dst[0] = smc->clcsock->sk->sk_daddr;
> }
Thanks, it looks like an AF_INET address indeed.
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170614/995396de/attachment.bin>
More information about the Strace-devel
mailing list