diff options
author | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-06-26 19:49:30 +0000 |
---|---|---|
committer | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-06-26 19:49:30 +0000 |
commit | 9424116e40f7e83c289da99358b68710fb409990 (patch) | |
tree | 45cfe784a844e5a6e0ea957c4eadb6db09f6312c /sys/netinet/ip_spd.c | |
parent | 04a10fb53b830b8e86bd8650451872831c55f4eb (diff) |
Rewrite ipsp_clear_acquire() to be more readable, after all the KNF'ing
Diffstat (limited to 'sys/netinet/ip_spd.c')
-rw-r--r-- | sys/netinet/ip_spd.c | 144 |
1 files changed, 69 insertions, 75 deletions
diff --git a/sys/netinet/ip_spd.c b/sys/netinet/ip_spd.c index 9f4b8a71895..05b2a4be960 100644 --- a/sys/netinet/ip_spd.c +++ b/sys/netinet/ip_spd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_spd.c,v 1.29 2001/06/26 19:01:27 angelos Exp $ */ +/* $OpenBSD: ip_spd.c,v 1.30 2001/06/26 19:49:29 angelos Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) * @@ -669,90 +669,84 @@ ipsp_clear_acquire(struct tdb *tdb) struct ifqueue *ifq; int s; - while ((ipa = ipsp_pending_acquire(&tdb->tdb_dst)) != NULL) { - /* Retransmit */ - if (ipa->ipa_packet) { - switch (ipa->ipa_info.sen_type) { + ipa = ipsec_get_acquire(tdb->tdb_seq); + if (ipa == NULL) + return; + + /* Just delete and return if no pending packet. */ + if (ipa->ipa_packet == NULL) { + ipsp_delete_acquire(ipa); + return; + } + + /* Retransmit last packet. */ + switch (ipa->ipa_info.sen_type) { #ifdef INET - case SENT_IP4: - { - struct ip *ip; - - switch (ipa->ipa_info.sen_direction) { - case IPSP_DIRECTION_OUT: - ip = mtod(ipa->ipa_packet, - struct ip *); - - if (ipa->ipa_packet->m_len < - sizeof(struct ip)) - break; - - /* - * Same as in ip_output() -- - * massage the header. - */ - ip->ip_len = - htons((u_short) ip->ip_len); - ip->ip_off = - htons((u_short) ip->ip_off); - ipa->ipa_packet->m_flags &= - ~(M_MCAST | M_BCAST); - - ipsp_process_packet(ipa->ipa_packet, - tdb, AF_INET, 0); - ipa->ipa_packet = NULL; - break; - - case IPSP_DIRECTION_IN: - ifq = &ipintrq; - s = splimp(); - if (IF_QFULL(ifq)) { - IF_DROP(ifq); - splx(s); - break; - } - IF_ENQUEUE(ifq, ipa->ipa_packet); - ipa->ipa_packet = NULL; - schednetisr(NETISR_IP); - splx(s); - break; - } + case SENT_IP4: + { + struct ip *ip; + + switch (ipa->ipa_info.sen_direction) { + case IPSP_DIRECTION_OUT: + ip = mtod(ipa->ipa_packet, struct ip *); + + if (ipa->ipa_packet->m_len < sizeof(struct ip)) + break; + + /* Same as in ip_output() -- massage the header. */ + ip->ip_len = htons((u_short) ip->ip_len); + ip->ip_off = htons((u_short) ip->ip_off); + + ipsp_process_packet(ipa->ipa_packet, tdb, AF_INET, 0); + ipa->ipa_packet = NULL; + break; + + case IPSP_DIRECTION_IN: + ifq = &ipintrq; + s = splimp(); + if (IF_QFULL(ifq)) { + IF_DROP(ifq); + splx(s); + break; } + IF_ENQUEUE(ifq, ipa->ipa_packet); + ipa->ipa_packet = NULL; + schednetisr(NETISR_IP); + splx(s); break; + } + } + break; #endif /* INET */ #ifdef INET6 - case SENT_IP6: - switch (ipa->ipa_info.sen_ip6_direction) { - case IPSP_DIRECTION_OUT: - ipa->ipa_packet->m_flags &= - ~(M_BCAST | M_MCAST); - ipsp_process_packet(ipa->ipa_packet, - tdb, AF_INET6, 0); - ipa->ipa_packet = NULL; - break; - - case IPSP_DIRECTION_IN: - ifq = &ip6intrq; - s = splimp(); - if (IF_QFULL(ifq)) { - IF_DROP(ifq); - splx(s); - break; - } - IF_ENQUEUE(ifq, ipa->ipa_packet); - ipa->ipa_packet = NULL; - schednetisr(NETISR_IPV6); - splx(s); - break; - } + case SENT_IP6: + switch (ipa->ipa_info.sen_ip6_direction) { + case IPSP_DIRECTION_OUT: + ipsp_process_packet(ipa->ipa_packet, tdb, AF_INET6, 0); + ipa->ipa_packet = NULL; + break; + + case IPSP_DIRECTION_IN: + ifq = &ip6intrq; + s = splimp(); + if (IF_QFULL(ifq)) { + IF_DROP(ifq); + splx(s); break; -#endif /* INET6 */ } + IF_ENQUEUE(ifq, ipa->ipa_packet); + ipa->ipa_packet = NULL; + schednetisr(NETISR_IPV6); + splx(s); + break; } - - ipsp_delete_acquire(ipa); + break; +#endif /* INET6 */ } + + /* Delete. */ + ipsp_delete_acquire(ipa); } /* |