Skip to content

Commit

Permalink
Fix translation of ESP warning messages
Browse files Browse the repository at this point in the history
In commit 4daac3f ("Save latest ESP sequence number even if replay
protection isn't in use") the messages for discarded packets were mangled
in a horribly untranslatable way. I should know better than that. Stupid
dwmw2; no biscuit.

Thanks to Marek Černocký for pointing it out.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
  • Loading branch information
dwmw2 committed Mar 13, 2018
1 parent 28126ca commit 497b3dd
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions esp-seqno.c
Expand Up @@ -32,14 +32,6 @@
int verify_packet_seqno(struct openconnect_info *vpninfo,
struct esp *esp, uint32_t seq)
{
int err_val = -EINVAL;
const char *discard_verb = "Discarding";

if (!vpninfo->esp_replay_protect) {
err_val = 0;
discard_verb = "Tolerating";
}

/*
* For incoming, esp->seq is the next *expected* packet, being
* the sequence number *after* the latest we have received.
Expand Down Expand Up @@ -107,17 +99,31 @@ int verify_packet_seqno(struct openconnect_info *vpninfo,
/* delta==0 is the overflow case where esp->seq is 0x100000000 and seq is 0 */
if (delta > 65 || delta == 0) {
/* Too old. We can't know if it's a replay. */
vpn_progress(vpninfo, PRG_DEBUG,
_("%s ancient ESP packet with seq %u (expected %" PRIu64 ")\n"),
discard_verb, seq, esp->seq);
return err_val;
if (vpninfo->esp_replay_protect) {
vpn_progress(vpninfo, PRG_DEBUG,
_("Discarding ancient ESP packet with seq %u (expected %" PRIu64 ")\n"),
seq, esp->seq);
return -EINVAL;
} else {
vpn_progress(vpninfo, PRG_DEBUG,
_("Tolerating ancient ESP packet with seq %u (expected %" PRIu64 ")\n"),
seq, esp->seq);
return 0;
}
} else if (delta == 1) {
/* Not in the bitmask since it is by definition already received. */
replayed:
vpn_progress(vpninfo, PRG_DEBUG,
_("%s replayed ESP packet with seq %u\n"),
discard_verb, seq);
return err_val;
if (vpninfo->esp_replay_protect) {
vpn_progress(vpninfo, PRG_DEBUG,
_("Discarding replayed ESP packet with seq %u\n"),
seq);
return -EINVAL;
} else {
vpn_progress(vpninfo, PRG_DEBUG,
_("Tolerating replayed ESP packet with seq %u\n"),
seq);
return 0;
}
} else {
/* Within the backlog window, so we remember whether we've seen it or not. */
uint64_t mask = 1ULL << (delta - 2);
Expand Down

0 comments on commit 497b3dd

Please sign in to comment.