diff options
author | Hiroki Sato <hrs@FreeBSD.org> | 2011-07-03 05:18:37 +0000 |
---|---|---|
committer | Hiroki Sato <hrs@FreeBSD.org> | 2011-07-03 05:18:37 +0000 |
commit | bfcc6c1858a99d44000e2aa81576ef3dfc5bb6d9 (patch) | |
tree | ca4dc5869b37fe5de06907a914dccc13ea23da09 /net/openbgpd/files/patch-bgpd_pfkey.c | |
parent | - Update to 0.91 (diff) |
- Update to a 4.9 snapshot as of 2011.06.12.
- Use USERS and GROUPS.
Diffstat (limited to 'net/openbgpd/files/patch-bgpd_pfkey.c')
-rw-r--r-- | net/openbgpd/files/patch-bgpd_pfkey.c | 86 |
1 files changed, 82 insertions, 4 deletions
diff --git a/net/openbgpd/files/patch-bgpd_pfkey.c b/net/openbgpd/files/patch-bgpd_pfkey.c index a7d261db35ea..f8e6845f1661 100644 --- a/net/openbgpd/files/patch-bgpd_pfkey.c +++ b/net/openbgpd/files/patch-bgpd_pfkey.c @@ -2,13 +2,13 @@ Index: bgpd/pfkey.c =================================================================== RCS file: /home/cvs/private/hrs/openbgpd/bgpd/pfkey.c,v retrieving revision 1.1.1.6 -retrieving revision 1.1.1.7 -diff -u -p -r1.1.1.6 -r1.1.1.7 +retrieving revision 1.1.1.8 +diff -u -p -r1.1.1.6 -r1.1.1.8 --- bgpd/pfkey.c 14 Feb 2010 20:19:57 -0000 1.1.1.6 -+++ bgpd/pfkey.c 14 Feb 2010 20:27:06 -0000 1.1.1.7 ++++ bgpd/pfkey.c 12 Jun 2011 10:44:25 -0000 1.1.1.8 @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkey.c,v 1.37 2009/04/21 15:25:52 henning Exp $ */ -+/* $OpenBSD: pfkey.c,v 1.40 2009/12/14 17:38:18 claudio Exp $ */ ++/* $OpenBSD: pfkey.c,v 1.41 2010/12/09 13:50:41 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -118,3 +118,81 @@ diff -u -p -r1.1.1.6 -r1.1.1.7 dmask.ss_len = sizeof(struct sockaddr_in6); dmask.ss_family = AF_INET6; memset(&((struct sockaddr_in6 *)&dmask)->sin6_addr, +@@ -411,6 +402,33 @@ pfkey_send(int sd, uint8_t satype, uint8 + } + + int ++pfkey_read(int sd, struct sadb_msg *h) ++{ ++ struct sadb_msg hdr; ++ ++ if (recv(sd, &hdr, sizeof(hdr), MSG_PEEK) != sizeof(hdr)) { ++ log_warn("pfkey peek"); ++ return (-1); ++ } ++ ++ /* XXX: Only one message can be outstanding. */ ++ if (hdr.sadb_msg_seq == sadb_msg_seq && ++ hdr.sadb_msg_pid == pid) { ++ if (h) ++ bcopy(&hdr, h, sizeof(hdr)); ++ return (0); ++ } ++ ++ /* not ours, discard */ ++ if (read(sd, &hdr, sizeof(hdr)) == -1) { ++ log_warn("pfkey read"); ++ return (-1); ++ } ++ ++ return (1); ++} ++ ++int + pfkey_reply(int sd, u_int32_t *spip) + { + struct sadb_msg hdr, *msg; +@@ -418,23 +436,13 @@ pfkey_reply(int sd, u_int32_t *spip) + struct sadb_sa *sa; + u_int8_t *data; + ssize_t len; ++ int rv; + +- for (;;) { +- if (recv(sd, &hdr, sizeof(hdr), MSG_PEEK) != sizeof(hdr)) { +- log_warn("pfkey peek"); ++ do { ++ rv = pfkey_read(sd, &hdr); ++ if (rv == -1) + return (-1); +- } +- +- if (hdr.sadb_msg_seq == sadb_msg_seq && +- hdr.sadb_msg_pid == pid) +- break; +- +- /* not ours, discard */ +- if (read(sd, &hdr, sizeof(hdr)) == -1) { +- log_warn("pfkey read"); +- return (-1); +- } +- } ++ } while (rv); + + if (hdr.sadb_msg_errno != 0) { + errno = hdr.sadb_msg_errno; +@@ -730,11 +738,9 @@ pfkey_init(struct bgpd_sysdep *sysdep) + if (errno == EPROTONOSUPPORT) { + log_warnx("PF_KEY not available, disabling ipsec"); + sysdep->no_pfkey = 1; +- return (0); +- } else { +- log_warn("PF_KEY socket"); + return (-1); +- } ++ } else ++ fatal("pfkey setup failed"); + } +- return (0); ++ return (fd); + } |