Repository navigation
ipsec: fix: emit packetDropped for the datagrams IPsec discards - #1362
Open
adamgeorge309 wants to merge 1 commit into
Open
adamgeorge309 wants to merge 1 commit into
adamgeorge309 wants to merge 1 commit into
Conversation
IPsec discarded a datagram by returning DROP from its netfilter hook after emitting only its own counter signals (outDrop, inUnprotectedDrop, inProtectedDrop), and the network layer deleted the datagram without emitting packetDropped either. PacketDropVisualizer, which subscribes to packetDropped, and the statistics and result filters built on it did not see Security Policy Database (SPD) discards or any other IPsec discard. A new member function, emitPacketDropped(), emits packetDropped with a PacketDropDetails reason, and each of the 14 sites that count a discard calls it before returning DROP: with LIFETIME_EXPIRED for the two inbound sites where the hard lifetime of the Security Association has ended or the packet would exceed its byte limit, and with OTHER_PACKET_DROP for the others, including an outbound datagram whose only Security Association has expired. At the six inbound Authentication Header (AH) and Encapsulating Security Payload (ESP) sites that have already removed the network header, the datagram is restored before the emit: as it reached AH or ESP processing where the AH or ESP header is still at hand (as received, unless AH covered ESP), and as AH or ESP processing gives it back at the two lifetime sites. The discard of an ESP dummy packet stays silent, because Request for Comments (RFC) 4303 Section 2.6 makes it normal operation. IPsec.ned declares the signal and records packetDropLifetimeExpired and packetDropUndefined, like Ipv4.ned. tests/module/IPsec_packet_dropped.test discards three datagrams by an outbound SPD DISCARD entry at the client, and at the server three unprotected datagrams that no inbound SPD entry matches and three ESP-protected datagrams whose Security Parameters Index (SPI) has no Security Association, and checks that packetDropUndefined counts each IPsec module's outDrop, inUnprotectedDrop and inProtectedDrop discards. No fingerprint changes. The statistical baselines of examples/inet/ipsec gain the new scalars. Change: src.networklayer.ipsec.IPsec | behavior.change.fix | test statistical whatsnew
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The IP Security (IPsec) module discarded datagrams without emitting
packetDropped, soPacketDropVisualizerand the statistics built on that signal did not see a Security Policy Database (SPD) DISCARD or any other IPsec discard. IPsec now emitspacketDroppedat each discard that it counts, andIPsec.nedrecords two per-reason statistics.Risk: low. Only signal emissions and statistics are added; no datagram is routed, delayed or deleted differently, and no fingerprint changes. In models with IPsec discards,
packetDroppedlisteners andPacketDropVisualizernow see them, and every IPsec module records new scalars.Closes #1361
One commit:
ipsec: fix: emit packetDropped for the datagrams IPsec discards.The problem
IPsec.ccon masterbba1db4c81returnsINetfilter::IHook::DROPat 14 sites after emittingoutDrop,inUnprotectedDroporinProtectedDrop, which arelongcounter signals. TheIpv4andIpv6hook dispatchers then delete the datagram (case INetfilter::IHook::DROP: delete packet;). Neither side emitspacketDropped, andIPsec.neddoes not declare it.The change
IPsec::emitPacketDropped(Packet *, PacketDropReason), a new private member function, emitspacketDroppedwith aPacketDropDetailsreason. The packet is still alive at that point; the network layer deletes it after the hook returns.LIFETIME_EXPIREDwhere an inbound packet arrives on a Security Association (SA) whose hard lifetime has ended or whose byte limit the packet would exceed (one site each for the Authentication Header (AH) and the Encapsulating Security Payload (ESP)),OTHER_PACKET_DROPat the other 12. An outbound datagram whose only matching SA has expired is skipped byprotectDatagram()'s SA loop and reaches the "no SA of the PROTECT entry matches" site, so it is reported asOTHER_PACKET_DROP. NoPacketDropReasondescribes a policy discard, so those useOTHER_PACKET_DROP.IPsec.cc:1040-1042on master) stays silent. Request for Comments (RFC) 4303 Section 2.6 has the receiver discard a dummy packet as normal operation, and it has no counter either.IPsec.ned:@signal[packetDropped](type=inet::Packet), and@statistic[packetDropLifetimeExpired]and@statistic[packetDropUndefined], written as inIpv4.ned.At six inbound AH and ESP sites,
removeNetworkHeader()has already run. Where the AH or ESP header is still at hand (the SA does not prescribe the protocol, or no SA has the Security Parameters Index (SPI)), the AH or ESP header and the network header are inserted back, which gives the datagram as received, or as AH processing gave it back when AH covers ESP. At the two lifetime sites, the network header is completed and inserted as on the accept path (setNetworkHeaderProtocol(),updateNetworkHeaderLength()), which gives the datagram as AH or ESP processing returns it. A listener that dissects the emitted packet therefore finds a network header at its front. In the new test, the six datagrams the server drops sum to 852 bytes, the bytes its Point-to-Point Protocol (PPP) interface received (894) minus 7 bytes of PPP framing each.LIFETIME_EXPIREDelsewhere in INET means that the packet's own lifetime has ended; here it means that the SA's lifetime has, which RFC 4301 Section 4.4.2.1 also calls a lifetime.No C++ interface outside
IPsec, Network Description (NED) parameter, message field or feature descriptor changes.Not addressed here: the log text "IPsec OUT BYPASS, no matching rule" at the outbound site with no matching SPD entry, which discards; other netfilter hooks that return
DROPwithout emittingpacketDropped(CloudDelayerBase,Gpsr,Mipv6,SctpNatHook).Verification
Release build (
make MODE=releasein the root andtests/module/lib), each suite run on masterbba1db4c81and with this change.New module test
tests/module/IPsec_packet_dropped.test: twoStandardHosts withhasIpsec = true. The client's SPD has an OUT entry with the action DISCARD for User Datagram Protocol (UDP) datagrams to port 2000 and an OUT entry with the action BYPASS for port 2001; the server's SPD is empty. A third OUT entry protects UDP traffic to port 2002 with ESP under SPI 7, for which the server has no SA. The client sends three datagrams to each port. The test checks thatclient.ipv4.ipsecrecordsoutDrop:count 3andpacketDropUndefined:count 3, andserver.ipv4.ipsecrecordsinUnprotectedDrop:count 3,inProtectedDrop:count 3("IPsec IN DROP ESP, no matching rule", one of the six sites above) andpacketDropUndefined:count 6. On master's source, the same counters are 3 andpacketDropUndefineddoes not exist, so the test fails.tests/fingerprint: ./fingerprinttest -s -F tyftests/module: inet_run_module_tests -m release --no-build -l ERRORIeee80211BlockAckVariant_1(below)Of the 289 module failures on master, 274 are
tcp_*tests and 15 areConvolutionalCoder12,ConvolutionalCoder34,DimensionalMediumAnalogModel_PrintAttenuation_1,EtherHost_lifecycle,ExternalProcess_3,Ieee80211BitDomain,Ieee80211BlockAckVariant_1,Ieee80211SymbolDomain,Ieee8021d-Rstp,Ieee8021d-Stp,IPv6_packet_too_big,LogNormalShadowing_Correlated_4,MIPv6_tcp_handover,PacketGate_1,UDPSocket_1. The 5 fingerprint failures are rows ofmipv6-refactoring.csvwhose recorded~tNlbfingerprints are stale on master; the 62 errors are configurations whose optional features are not built.Ieee80211BlockAckVariant_1runs a debug build of INET (check-profile.py) and fails with "INET debug executable or shared library not found" where there is none. The worktree of this change has a debug build from earlier work and the master worktree does not; the test does not involve IPsec.Statistical baselines (statistics repository, origin/master): the six
examples/inet/ipsecbaselines gain the new scalars. In bothomnetpp.iniandipv6.ini,client1recordsoutDropcounts of 40 and 7, which the newpacketDropUndefinedcounts too. They need re-recording after merge.Gates:
check-pull-request.sh --base origin/master(commits, classification, includes, NED parameters, description),check-source-seals.sh --base origin/masterandcheck-architecture.sh src/inet/networklayer/ipsecpass.Relationship to other pull requests
PACKET_TOO_BIGpull request (common: add: a PACKET_TOO_BIG packet drop reason #1360) adds a drop reason in the same enum; this change does not use it and does not depend on it.WHATSNEW; whichever merges later renumbers.