XFRM - Cleanup of XfrmId Usage Inconsistencies
The XfrmId contains all the fields that are required
to identify an SA or a policy during either creation
or deletion. This patch improves the consistency of
creating the internal XfrmId structure that we pass
around in the XfrmController.
Bug: 70594971
Test: runtest -x system/netd/server/netd_unit_test.cpp
Test: cts passes
Change-Id: I39b9ed1599ef65ca957866b0dcb37726e33c53fa
diff --git a/server/XfrmController.h b/server/XfrmController.h
index 7e508a0..a881b64 100644
--- a/server/XfrmController.h
+++ b/server/XfrmController.h
@@ -99,7 +99,8 @@
uint16_t dstPort;
};
-struct XfrmSaId {
+// minimally sufficient structure to match either an SA or a Policy
+struct XfrmId {
XfrmDirection direction;
xfrm_address_t dstAddr; // network order
xfrm_address_t srcAddr;
@@ -108,7 +109,7 @@
int spi;
};
-struct XfrmSaInfo : XfrmSaId {
+struct XfrmSaInfo : XfrmId {
XfrmAlgo auth;
XfrmAlgo crypt;
XfrmAlgo aead;
@@ -233,10 +234,10 @@
"struct xfrm_userspi_info has changed and does not match the kernel struct.");
#endif
- // helper function for filling in the XfrmSaInfo structure
- static netdutils::Status fillXfrmSaId(int32_t direction, const std::string& localAddress,
+ // helper function for filling in the XfrmId (and XfrmSaInfo) structure
+ static netdutils::Status fillXfrmId(int32_t direction, const std::string& localAddress,
const std::string& remoteAddress, int32_t spi,
- XfrmSaId* xfrmId);
+ int32_t transformId, XfrmId* xfrmId);
// Top level functions for managing a Transport Mode Transform
static netdutils::Status addTransportModeTransform(const XfrmSaInfo& record);
@@ -258,9 +259,9 @@
static int fillUserSaInfo(const XfrmSaInfo& record, xfrm_usersa_info* usersa);
// Functions for deleting a Transport Mode SA
- static netdutils::Status deleteSecurityAssociation(const XfrmSaId& record,
+ static netdutils::Status deleteSecurityAssociation(const XfrmId& record,
const XfrmSocket& sock);
- static int fillUserSaId(const XfrmSaId& record, xfrm_usersa_id* said);
+ static int fillUserSaId(const XfrmId& record, xfrm_usersa_id* said);
static int fillUserTemplate(const XfrmSaInfo& record, xfrm_user_tmpl* tmpl);
static int fillTransportModeUserSpInfo(const XfrmSaInfo& record, xfrm_userpolicy_info* usersp);