diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2009-04-21 15:25:53 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2009-04-21 15:25:53 +0000 |
commit | 342b37cf6cf13c00caca1c349dff4a188a900242 (patch) | |
tree | ae28ddc098d0d91263f788b1b2e5d1a4c55b3b7c | |
parent | 6990b8260a7d4eb2f3f2209cd7f7d5d27c8935da (diff) |
instead of calling getpid() all over the place do it once, claudio ok
-rw-r--r-- | usr.sbin/bgpd/pfkey.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/bgpd/pfkey.c b/usr.sbin/bgpd/pfkey.c index ba5bfa7da1c..80936f4cc62 100644 --- a/usr.sbin/bgpd/pfkey.c +++ b/usr.sbin/bgpd/pfkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkey.c,v 1.36 2009/04/21 13:57:14 henning Exp $ */ +/* $OpenBSD: pfkey.c,v 1.37 2009/04/21 15:25:52 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -37,6 +37,7 @@ #define IOV_CNT 20 static u_int32_t sadb_msg_seq = 0; +static u_int32_t pid = 0; /* should pid_t but pfkey needs u_int32_t */ static int fd; int pfkey_reply(int, u_int32_t *); @@ -74,6 +75,9 @@ pfkey_send(int sd, uint8_t satype, uint8_t mtype, uint8_t dir, int iov_cnt; struct sockaddr_storage ssrc, sdst, speer, smask, dmask; + if (!pid) + pid = getpid(); + /* we need clean sockaddr... no ports set */ bzero(&ssrc, sizeof(ssrc)); bzero(&smask, sizeof(smask)); @@ -130,7 +134,7 @@ pfkey_send(int sd, uint8_t satype, uint8_t mtype, uint8_t dir, bzero(&smsg, sizeof(smsg)); smsg.sadb_msg_version = PF_KEY_V2; smsg.sadb_msg_seq = ++sadb_msg_seq; - smsg.sadb_msg_pid = getpid(); + smsg.sadb_msg_pid = pid; smsg.sadb_msg_len = sizeof(smsg) / 8; smsg.sadb_msg_type = mtype; smsg.sadb_msg_satype = satype; @@ -422,7 +426,7 @@ pfkey_reply(int sd, u_int32_t *spip) } if (hdr.sadb_msg_seq == sadb_msg_seq && - hdr.sadb_msg_pid == getpid()) + hdr.sadb_msg_pid == pid) break; /* not ours, discard */ |