Messages in this thread | | | Date | Wed, 9 Mar 2022 15:32:33 +0800 | From | Mingbao Sun <> | Subject | Re: [PATCH v2 2/2] nvme-tcp: support specifying the congestion-control |
| |
> > @@ -1447,6 +1449,21 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, > > if (nctrl->opts->tos >= 0) > > ip_sock_set_tos(queue->sock->sk, nctrl->opts->tos); > > > > + if (nctrl->opts->mask & NVMF_OPT_TCP_CONGESTION) { > > + strncpy(ca_name, nctrl->opts->tcp_congestion, > > + TCP_CA_NAME_MAX-1); > > + optval = KERNEL_SOCKPTR(ca_name); > > + ret = sock_common_setsockopt(queue->sock, IPPROTO_TCP, > > + TCP_CONGESTION, optval, > > + strlen(ca_name)); > > This needs to use kernel_setsockopt. I also can see absolutely no > need for the optval local variable, and I also don't really see why > we need ca_name either - if we need to limit the length and terminate > it (but why?) that can be done during option parsing.
Well, actually at the beginning I did use kernel_setsockopt. But the compilation failed.
Then I found the API kernel_setsockopt disappeared from kernel v5.8. So I use sock_common_setsockopt instead. The birth of variable ca_name and optval is just because of the the relevant definitions related to the prototype of sock_common_setsockopt.
But now through thinking your comments and investigating the story of the disappearance of kernel_setsockopt, I feel I should use tcp_set_congestion_control instead of sock_common_setsockopt. Just as target/tcp.c replaced kernel_setsockopt with ip_sock_set_tos.
As for the length limitation of the ca name, I will (if required) move them into the phase of option parsing in the next version.
| |