@@ -109,6 +109,8 @@ void TunnelDecapOrch::doDecapTunnelTask(Consumer &consumer)
109109
110110 sai_object_id_t tunnel_id = SAI_NULL_OBJECT_ID;
111111
112+ // track whether any oper fields changed on this key
113+ bool state_changed = false ;
112114 // checking to see if the tunnel already exists
113115 bool exists = (tunnelTable.find (key) != tunnelTable.end ());
114116 if (exists)
@@ -160,8 +162,10 @@ void TunnelDecapOrch::doDecapTunnelTask(Consumer &consumer)
160162 }
161163 if (exists)
162164 {
165+ // Apply to SAI; only touch cache/flag on success
163166 setTunnelAttribute (fvField (i), dscp_mode, tunnel_id);
164167 tunnelTable[key].dscp_mode = dscp_mode;
168+ state_changed = true ;
165169 }
166170 }
167171 else if (fvField (i) == " ecn_mode" )
@@ -207,7 +211,9 @@ void TunnelDecapOrch::doDecapTunnelTask(Consumer &consumer)
207211 }
208212 if (exists)
209213 {
214+ // Apply to SAI; only touch cache/flag on success
210215 setTunnelAttribute (fvField (i), ttl_mode, tunnel_id);
216+ state_changed = true ;
211217 }
212218 }
213219 else if (fvField (i) == decap_dscp_to_tc_field_name)
@@ -221,7 +227,9 @@ void TunnelDecapOrch::doDecapTunnelTask(Consumer &consumer)
221227 }
222228 if (exists)
223229 {
230+ // Apply to SAI; only touch cache/flag on success
224231 setTunnelAttribute (fvField (i), dscp_to_tc_map_id, tunnel_id);
232+ state_changed = true ;
225233 }
226234 }
227235 else if (fvField (i) == decap_tc_to_pg_field_name)
@@ -235,7 +243,9 @@ void TunnelDecapOrch::doDecapTunnelTask(Consumer &consumer)
235243 }
236244 if (exists)
237245 {
246+ // Apply to SAI; only touch cache/flag on success
238247 setTunnelAttribute (fvField (i), tc_to_pg_map_id, tunnel_id);
248+ state_changed = true ;
239249 }
240250 }
241251 else if (fvField (i) == encap_tc_to_dscp_field_name)
@@ -251,6 +261,7 @@ void TunnelDecapOrch::doDecapTunnelTask(Consumer &consumer)
251261 {
252262 // Record only
253263 tunnelTable[key].encap_tc_to_dscp_map_id = tc_to_dscp_map_id;
264+ state_changed = true ;
254265 }
255266 }
256267 else if (fvField (i) == encap_tc_to_queue_field_name)
@@ -266,6 +277,7 @@ void TunnelDecapOrch::doDecapTunnelTask(Consumer &consumer)
266277 {
267278 // Record only
268279 tunnelTable[key].encap_tc_to_queue_map_id = tc_to_queue_map_id;
280+ state_changed = true ;
269281 }
270282 }
271283 else
@@ -276,6 +288,11 @@ void TunnelDecapOrch::doDecapTunnelTask(Consumer &consumer)
276288 }
277289 }
278290
291+ if (exists && state_changed) {
292+ // Publish to STATE_DB if any mirrored field changed
293+ setDecapTunnelStatus (key);
294+ }
295+
279296 if (task_status == task_process_status::task_need_retry)
280297 {
281298 ++it;
0 commit comments