@@ -100,36 +100,45 @@ func (pdrContext *PDRCreationContext) extractPDR(pdr *ie.IE, spdrInfo *SPDRInfo)
100100 }
101101 }
102102
103- if teidPdiId := findIEindex (pdi , 21 ); teidPdiId != - 1 { // IE Type F-TEID
104- if fteid , err := pdi [teidPdiId ].FTEID (); err == nil {
105- var teid = fteid .TEID
106- if fteid .HasCh () {
107- var allocate = true
108- if fteid .HasChID () {
109- if teidFromCache , ok := pdrContext .hasTEIDCache (fteid .ChooseID ); ok {
110- allocate = false
111- teid = teidFromCache
112- spdrInfo .Allocated = true
113- }
114- }
115- if allocate {
116- allocatedTeid , err := pdrContext .getFTEID (pdrContext .Session .RemoteSEID , spdrInfo .PdrID )
117- if err != nil {
118- log .Error ().Msgf ("AllocateTEID err: %v" , err )
119- return fmt .Errorf ("can't allocate TEID: %s" , causeToString (ie .CauseNoResourcesAvailable ))
120- }
121- teid = allocatedTeid
103+ if teidPdiId := findIEindex (pdi , ie .FTEID ); teidPdiId != - 1 {
104+ fteid , err := pdi [teidPdiId ].FTEID ()
105+ if err != nil {
106+ return fmt .Errorf ("F-TEID IE is missing" )
107+ }
108+
109+ var teid = fteid .TEID
110+ if fteid .HasCh () {
111+ var allocate = true
112+ if fteid .HasChID () {
113+ if teidFromCache , ok := pdrContext .hasTEIDCache (fteid .ChooseID ); ok {
114+ allocate = false
115+ teid = teidFromCache
122116 spdrInfo .Allocated = true
123- if fteid .HasChID () {
124- pdrContext .setTEIDCache (fteid .ChooseID , teid )
125- }
126117 }
127118 }
128- spdrInfo .Teid = teid
129- return nil
119+ if allocate {
120+ allocatedTeid , err := pdrContext .getFTEID (pdrContext .Session .RemoteSEID , spdrInfo .PdrID )
121+ if err != nil {
122+ log .Error ().Msgf ("AllocateTEID err: %v" , err )
123+ return fmt .Errorf ("can't allocate TEID: %s" , causeToString (ie .CauseNoResourcesAvailable ))
124+ }
125+ teid = allocatedTeid
126+ spdrInfo .Allocated = true
127+ if fteid .HasChID () {
128+ pdrContext .setTEIDCache (fteid .ChooseID , teid )
129+ }
130+ }
130131 }
131- return fmt .Errorf ("F-TEID IE is missing" )
132- } else if ueIP , err := pdr .UEIPAddress (); err == nil {
132+ spdrInfo .Teid = teid
133+ return nil
134+ }
135+
136+ if ueipPdiId := findIEindex (pdi , ie .UEIPAddress ); ueipPdiId != - 1 {
137+ ueIP , err := pdi [ueipPdiId ].UEIPAddress ()
138+ if err != nil {
139+ return fmt .Errorf ("UE IP Address IE is missing" )
140+ }
141+
133142 if config .Conf .FeatureUEIP && hasCHV4 (ueIP .Flags ) {
134143 if ip , err := pdrContext .getIP (); err == nil {
135144 ueIP .IPv4Address = cloneIP (ip )
@@ -147,10 +156,10 @@ func (pdrContext *PDRCreationContext) extractPDR(pdr *ie.IE, spdrInfo *SPDRInfo)
147156 }
148157
149158 return nil
150- } else {
151- log .Info ().Msg ("Both F-TEID IE and UE IP Address IE are missing" )
152- return err
153159 }
160+
161+ log .Info ().Msg ("Both F-TEID IE and UE IP Address IE are missing" )
162+ return err
154163}
155164
156165func (pdrContext * PDRCreationContext ) deletePDR (spdrInfo SPDRInfo , mapOperations ebpf.ForwardingPlaneController ) error {
0 commit comments