Re: pfkeyv2 rename struct keycb pointer

2017-07-24 Thread Alexander Bluhm
On Sat, Jul 22, 2017 at 12:47:55PM +0200, Claudio Jeker wrote:
> Suggested by bluhm@, switch from struct keycb *pk to struct keycb *kp.
> 
> OK?

OK bluhm@, this is more consistent with other PCB code.

> @@ -942,7 +942,7 @@ pfkeyv2_send(struct socket *so, void *me
>   struct radix_node_head *rnh;
>   struct radix_node *rn = NULL;
>  
> - struct keycb *pk, *bpk = NULL;
> + struct keycb *kp, *bkp = NULL;
>  
>   void *freeme = NULL, *bckptr = NULL;
>   void *headers[SADB_EXT_MAX + 1];

And I recommended to not intialize bkp, it is a loop variable.



pfkeyv2 rename struct keycb pointer

2017-07-22 Thread Claudio Jeker
Suggested by bluhm@, switch from struct keycb *pk to struct keycb *kp.

OK?
-- 
:wq Claudio

Index: net/pfkeyv2.c
===
RCS file: /cvs/src/sys/net/pfkeyv2.c,v
retrieving revision 1.163
diff -u -p -r1.163 pfkeyv2.c
--- net/pfkeyv2.c   3 Jul 2017 19:23:47 -   1.163
+++ net/pfkeyv2.c   10 Jul 2017 06:28:58 -
@@ -214,19 +214,19 @@ int
 pfkeyv2_attach(struct socket *so, int proto)
 {
struct rawcb *rp;
-   struct keycb *pk;
+   struct keycb *kp;
int error;
 
if ((so->so_state & SS_PRIV) == 0)
return EACCES;
 
-   pk = malloc(sizeof(struct keycb), M_PCB, M_WAITOK | M_ZERO);
-   rp = &pk->rcb;
+   kp = malloc(sizeof(struct keycb), M_PCB, M_WAITOK | M_ZERO);
+   rp = &kp->rcb;
so->so_pcb = rp;
 
error = raw_attach(so, proto);
if (error) {
-   free(pk, M_PCB, sizeof(struct keycb));
+   free(kp, M_PCB, sizeof(struct keycb));
return (error);
}
 
@@ -234,15 +234,15 @@ pfkeyv2_attach(struct socket *so, int pr
soisconnected(so);
 
rp->rcb_faddr = &pfkey_addr;
-   pk->pid = curproc->p_p->ps_pid;
+   kp->pid = curproc->p_p->ps_pid;
 
/*
 * XXX we should get this from the socket instead but
 * XXX rawcb doesn't store the rdomain like inpcb does.
 */
-   pk->rdomain = rtable_l2(curproc->p_p->ps_rtableid);
+   kp->rdomain = rtable_l2(curproc->p_p->ps_rtableid);
 
-   LIST_INSERT_HEAD(&pfkeyv2_sockets, pk, kcb_list);
+   LIST_INSERT_HEAD(&pfkeyv2_sockets, kp, kcb_list);
 
return (0);
 }
@@ -253,21 +253,21 @@ pfkeyv2_attach(struct socket *so, int pr
 int
 pfkeyv2_detach(struct socket *so, struct proc *p)
 {
-   struct keycb *pk;
+   struct keycb *kp;
 
-   pk = sotokeycb(so);
-   if (pk == NULL)
+   kp = sotokeycb(so);
+   if (kp == NULL)
return ENOTCONN;
 
-   LIST_REMOVE(pk, kcb_list);
+   LIST_REMOVE(kp, kcb_list);
 
-   if (pk->flags & PFKEYV2_SOCKETFLAGS_REGISTERED)
+   if (kp->flags & PFKEYV2_SOCKETFLAGS_REGISTERED)
nregistered--;
 
-   if (pk->flags & PFKEYV2_SOCKETFLAGS_PROMISC)
+   if (kp->flags & PFKEYV2_SOCKETFLAGS_PROMISC)
npromisc--;
 
-   raw_detach(&pk->rcb);
+   raw_detach(&kp->rcb);
return (0);
 }
 
@@ -942,7 +942,7 @@ pfkeyv2_send(struct socket *so, void *me
struct radix_node_head *rnh;
struct radix_node *rn = NULL;
 
-   struct keycb *pk, *bpk = NULL;
+   struct keycb *kp, *bkp = NULL;
 
void *freeme = NULL, *bckptr = NULL;
void *headers[SADB_EXT_MAX + 1];
@@ -964,14 +964,13 @@ pfkeyv2_send(struct socket *so, void *me
/* Verify that we received this over a legitimate pfkeyv2 socket */
bzero(headers, sizeof(headers));
 
-   pk = sotokeycb(so);
-
-   if (!pk) {
+   kp = sotokeycb(so);
+   if (!kp) {
rval = EINVAL;
goto ret;
}
 
-   rdomain = pk->rdomain;
+   rdomain = kp->rdomain;
 
/* If we have any promiscuous listeners, send them a copy of the 
message */
if (npromisc) {
@@ -1000,10 +999,10 @@ pfkeyv2_send(struct socket *so, void *me
goto ret;
 
/* Send to all promiscuous listeners */
-   LIST_FOREACH(bpk, &pfkeyv2_sockets, kcb_list) {
-   if ((bpk->flags & PFKEYV2_SOCKETFLAGS_PROMISC) &&
-   (bpk->rdomain == rdomain))
-   pfkey_sendup(bpk, packet, 1);
+   LIST_FOREACH(bkp, &pfkeyv2_sockets, kcb_list) {
+   if ((bkp->flags & PFKEYV2_SOCKETFLAGS_PROMISC) &&
+   (bkp->rdomain == rdomain))
+   pfkey_sendup(bkp, packet, 1);
}
 
m_freem(packet);
@@ -1392,8 +1391,8 @@ pfkeyv2_send(struct socket *so, void *me
break;
 
case SADB_REGISTER:
-   if (!(pk->flags & PFKEYV2_SOCKETFLAGS_REGISTERED)) {
-   pk->flags |= PFKEYV2_SOCKETFLAGS_REGISTERED;
+   if (!(kp->flags & PFKEYV2_SOCKETFLAGS_REGISTERED)) {
+   kp->flags |= PFKEYV2_SOCKETFLAGS_REGISTERED;
nregistered++;
}
 
@@ -1423,7 +1422,7 @@ pfkeyv2_send(struct socket *so, void *me
}
 
/* Keep track what this socket has registered for */
-   pk->registration |= (1 << ((struct sadb_msg 
*)message)->sadb_msg_satype);
+   kp->registration |= (1 << ((struct sadb_msg 
*)message)->sadb_msg_satype);
 
ssup = (struct sadb_supported *) freeme;
ssup->sadb_supported_len = i / sizeof(uint64_t);
@@ -1768,12 +1767,12 @@ pfkeyv2_send(struct socket *so, void *me
if ((rval = pfdata