@@ -105,6 +105,8 @@ static int zebra_sr_policy_notify_update_client(struct zebra_sr_policy *policy,
105
105
uint32_t message = 0 ;
106
106
unsigned long nump = 0 ;
107
107
uint8_t num ;
108
+ struct zapi_nexthop znh ;
109
+ int ret ;
108
110
109
111
/* Get output stream. */
110
112
s = stream_new (ZEBRA_MAX_PACKET_SIZ );
@@ -149,35 +151,11 @@ static int zebra_sr_policy_notify_update_client(struct zebra_sr_policy *policy,
149
151
stream_putc (s , 0 );
150
152
}
151
153
152
- stream_putl (s , nhlfe -> nexthop -> vrf_id );
153
- stream_putc (s , nhlfe -> nexthop -> type );
154
- switch (nhlfe -> nexthop -> type ) {
155
- case NEXTHOP_TYPE_IPV4 :
156
- case NEXTHOP_TYPE_IPV4_IFINDEX :
157
- stream_put_in_addr (s , & nhlfe -> nexthop -> gate .ipv4 );
158
- stream_putl (s , nhlfe -> nexthop -> ifindex );
159
- break ;
160
- case NEXTHOP_TYPE_IFINDEX :
161
- stream_putl (s , nhlfe -> nexthop -> ifindex );
162
- break ;
163
- case NEXTHOP_TYPE_IPV6 :
164
- case NEXTHOP_TYPE_IPV6_IFINDEX :
165
- stream_put (s , & nhlfe -> nexthop -> gate .ipv6 , 16 );
166
- stream_putl (s , nhlfe -> nexthop -> ifindex );
167
- break ;
168
- default :
169
- /* do nothing */
170
- break ;
171
- }
172
- if (nhlfe -> nexthop -> nh_label ) {
173
- stream_putc (s , nhlfe -> nexthop -> nh_label -> num_labels );
174
- if (nhlfe -> nexthop -> nh_label -> num_labels )
175
- stream_put (s ,
176
- & nhlfe -> nexthop -> nh_label -> label [0 ],
177
- nhlfe -> nexthop -> nh_label -> num_labels
178
- * sizeof (mpls_label_t ));
179
- } else
180
- stream_putc (s , 0 );
154
+ zapi_nexthop_from_nexthop (& znh , nhlfe -> nexthop );
155
+ ret = zapi_nexthop_encode (s , & znh , 0 , message );
156
+ if (ret < 0 )
157
+ goto failure ;
158
+
181
159
num ++ ;
182
160
}
183
161
stream_putc_at (s , nump , num );
@@ -186,6 +164,11 @@ static int zebra_sr_policy_notify_update_client(struct zebra_sr_policy *policy,
186
164
client -> nh_last_upd_time = monotime (NULL );
187
165
client -> last_write_cmd = ZEBRA_NEXTHOP_UPDATE ;
188
166
return zserv_send_message (client , s );
167
+
168
+ failure :
169
+
170
+ stream_free (s );
171
+ return -1 ;
189
172
}
190
173
191
174
static void zebra_sr_policy_notify_update (struct zebra_sr_policy * policy )
0 commit comments