net/xfrm/xfrm_replay.c
Source file repositories/reference/linux-study-clean/net/xfrm/xfrm_replay.c
File Facts
- System
- Linux kernel
- Corpus path
net/xfrm/xfrm_replay.c- Extension
.c- Size
- 19243 bytes
- Lines
- 800
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hnet/xfrm.h
Detected Declarations
function Copyrightfunction xfrm_replay_notifyfunction __xfrm_replay_overflowfunction xfrm_replay_check_legacyfunction xfrm_replay_advancefunction xfrm_replay_overflow_bmpfunction xfrm_replay_check_bmpfunction xfrm_replay_advance_bmpfunction xfrm_replay_notify_bmpfunction xfrm_replay_notify_esnfunction xfrm_replay_overflow_esnfunction xfrm_replay_check_esnfunction xfrm_replay_checkfunction xfrm_replay_recheck_esnfunction xfrm_replay_recheckfunction xfrm_replay_advance_esnfunction xfrm_replay_overflow_offloadfunction xfrm_replay_overflow_offload_bmpfunction xfrm_replay_overflow_offload_esnfunction xfrm_replay_overflowfunction xfrm_replay_overflowfunction xfrm_init_replayexport xfrm_replay_seqhiexport xfrm_init_replay
Annotated Snippet
sizeof(struct xfrm_replay_state)) == 0) {
x->xflags |= XFRM_TIME_DEFER;
return;
}
break;
}
memcpy(&x->preplay, &x->replay, sizeof(struct xfrm_replay_state));
c.event = XFRM_MSG_NEWAE;
c.data.aevent = event;
km_state_notify(x, &c);
if (x->replay_maxage &&
!mod_timer(&x->rtimer, jiffies + x->replay_maxage))
x->xflags &= ~XFRM_TIME_DEFER;
}
static int __xfrm_replay_overflow(struct xfrm_state *x, struct sk_buff *skb)
{
int err = 0;
struct net *net = xs_net(x);
if (x->type->flags & XFRM_TYPE_REPLAY_PROT) {
XFRM_SKB_CB(skb)->seq.output.low = ++x->replay.oseq;
XFRM_SKB_CB(skb)->seq.output.hi = 0;
if (unlikely(x->replay.oseq == 0) &&
!(x->props.extra_flags & XFRM_SA_XFLAG_OSEQ_MAY_WRAP)) {
x->replay.oseq--;
xfrm_audit_state_replay_overflow(x, skb);
err = -EOVERFLOW;
return err;
}
if (xfrm_aevent_is_on(net))
xfrm_replay_notify(x, XFRM_REPLAY_UPDATE);
}
return err;
}
static int xfrm_replay_check_legacy(struct xfrm_state *x,
struct sk_buff *skb, __be32 net_seq)
{
u32 diff;
u32 seq = ntohl(net_seq);
if (!x->props.replay_window)
return 0;
if (unlikely(seq == 0))
goto err;
if (likely(seq > x->replay.seq))
return 0;
diff = x->replay.seq - seq;
if (diff >= x->props.replay_window) {
x->stats.replay_window++;
goto err;
}
if (x->replay.bitmap & (1U << diff)) {
x->stats.replay++;
goto err;
}
return 0;
err:
xfrm_audit_state_replay(x, skb, net_seq);
return -EINVAL;
}
static void xfrm_replay_advance_bmp(struct xfrm_state *x, __be32 net_seq);
static void xfrm_replay_advance_esn(struct xfrm_state *x, __be32 net_seq);
void xfrm_replay_advance(struct xfrm_state *x, __be32 net_seq)
{
u32 diff, seq;
switch (x->repl_mode) {
case XFRM_REPLAY_MODE_LEGACY:
break;
case XFRM_REPLAY_MODE_BMP:
return xfrm_replay_advance_bmp(x, net_seq);
case XFRM_REPLAY_MODE_ESN:
return xfrm_replay_advance_esn(x, net_seq);
}
if (!x->props.replay_window)
Annotation
- Immediate include surface: `linux/export.h`, `net/xfrm.h`.
- Detected declarations: `function Copyright`, `function xfrm_replay_notify`, `function __xfrm_replay_overflow`, `function xfrm_replay_check_legacy`, `function xfrm_replay_advance`, `function xfrm_replay_overflow_bmp`, `function xfrm_replay_check_bmp`, `function xfrm_replay_advance_bmp`, `function xfrm_replay_notify_bmp`, `function xfrm_replay_notify_esn`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.