@@ -113,7 +113,9 @@ type XfrmState struct {
113113 Statistics XfrmStateStats
114114 Mark * XfrmMark
115115 OutputMark * XfrmMark
116+ SADir SADir
116117 Ifid int
118+ Pcpunum * uint32
117119 Auth * XfrmStateAlgo
118120 Crypt * XfrmStateAlgo
119121 Aead * XfrmStateAlgo
@@ -126,8 +128,8 @@ type XfrmState struct {
126128}
127129
128130func (sa XfrmState ) String () string {
129- return fmt .Sprintf ("Dst: %v, Src: %v, Proto: %s, Mode: %s, SPI: 0x%x, ReqID: 0x%x, ReplayWindow: %d, Mark: %v, OutputMark: %v, Ifid: %d, Auth: %v, Crypt: %v, Aead: %v, Encap: %v, ESN: %t, DontEncapDSCP: %t, OSeqMayWrap: %t, Replay: %v" ,
130- sa .Dst , sa .Src , sa .Proto , sa .Mode , sa .Spi , sa .Reqid , sa .ReplayWindow , sa .Mark , sa .OutputMark , sa .Ifid , sa .Auth , sa .Crypt , sa .Aead , sa .Encap , sa .ESN , sa .DontEncapDSCP , sa .OSeqMayWrap , sa .Replay )
131+ return fmt .Sprintf ("Dst: %v, Src: %v, Proto: %s, Mode: %s, SPI: 0x%x, ReqID: 0x%x, ReplayWindow: %d, Mark: %v, OutputMark: %v, SADir: %d, Ifid: %d, Pcpunum : %d, Auth: %v, Crypt: %v, Aead: %v, Encap: %v, ESN: %t, DontEncapDSCP: %t, OSeqMayWrap: %t, Replay: %v" ,
132+ sa .Dst , sa .Src , sa .Proto , sa .Mode , sa .Spi , sa .Reqid , sa .ReplayWindow , sa .Mark , sa .OutputMark , sa .SADir , sa . Ifid , * sa . Pcpunum , sa .Auth , sa .Crypt , sa .Aead , sa .Encap , sa .ESN , sa .DontEncapDSCP , sa .OSeqMayWrap , sa .Replay )
131133}
132134func (sa XfrmState ) Print (stats bool ) string {
133135 if ! stats {
@@ -333,11 +335,21 @@ func (h *Handle) xfrmStateAddOrUpdate(state *XfrmState, nlProto int) error {
333335 req .AddData (out )
334336 }
335337
338+ if state .SADir != 0 {
339+ saDir := nl .NewRtAttr (nl .XFRMA_SA_DIR , nl .Uint8Attr (uint8 (state .SADir )))
340+ req .AddData (saDir )
341+ }
342+
336343 if state .Ifid != 0 {
337344 ifId := nl .NewRtAttr (nl .XFRMA_IF_ID , nl .Uint32Attr (uint32 (state .Ifid )))
338345 req .AddData (ifId )
339346 }
340347
348+ if state .Pcpunum != nil {
349+ pcpuNum := nl .NewRtAttr (nl .XFRMA_SA_PCPU , nl .Uint32Attr (uint32 (* state .Pcpunum )))
350+ req .AddData (pcpuNum )
351+ }
352+
341353 _ , err := req .Execute (unix .NETLINK_XFRM , 0 )
342354 return err
343355}
@@ -459,6 +471,11 @@ func (h *Handle) xfrmStateGetOrDelete(state *XfrmState, nlProto int) (*XfrmState
459471 req .AddData (ifId )
460472 }
461473
474+ if state .Pcpunum != nil {
475+ pcpuNum := nl .NewRtAttr (nl .XFRMA_SA_PCPU , nl .Uint32Attr (uint32 (* state .Pcpunum )))
476+ req .AddData (pcpuNum )
477+ }
478+
462479 resType := nl .XFRM_MSG_NEWSA
463480 if nlProto == nl .XFRM_MSG_DELSA {
464481 resType = 0
@@ -581,8 +598,13 @@ func parseXfrmState(m []byte, family int) (*XfrmState, error) {
581598 if state .OutputMark .Mask == 0xffffffff {
582599 state .OutputMark .Mask = 0
583600 }
601+ case nl .XFRMA_SA_DIR :
602+ state .SADir = SADir (attr .Value [0 ])
584603 case nl .XFRMA_IF_ID :
585604 state .Ifid = int (native .Uint32 (attr .Value ))
605+ case nl .XFRMA_SA_PCPU :
606+ pcpuNum := native .Uint32 (attr .Value )
607+ state .Pcpunum = & pcpuNum
586608 case nl .XFRMA_REPLAY_VAL :
587609 if state .Replay == nil {
588610 state .Replay = new (XfrmReplayState )
0 commit comments