@@ -937,36 +937,38 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
937937 afi = AFI_IP6 ;
938938
939939 if (h -> nlmsg_type == RTM_NEWROUTE ) {
940+ struct route_entry * re ;
941+ struct nexthop_group * ng = NULL ;
942+
943+ re = zebra_rib_route_entry_new (vrf_id , proto , 0 , flags , nhe_id ,
944+ table , metric , mtu , distance ,
945+ tag );
946+ if (!nhe_id )
947+ ng = nexthop_group_new ();
940948
941949 if (!tb [RTA_MULTIPATH ]) {
942- struct nexthop nh = { 0 } ;
950+ struct nexthop * nexthop , nh ;
943951
944952 if (!nhe_id ) {
945953 nh = parse_nexthop_unicast (
946954 ns_id , rtm , tb , bh_type , index , prefsrc ,
947955 gate , afi , vrf_id );
956+
957+ nexthop = nexthop_new ();
958+ * nexthop = nh ;
959+ nexthop_group_add_sorted (ng , nexthop );
948960 }
949- rib_add (afi , SAFI_UNICAST , vrf_id , proto , 0 , flags , & p ,
950- & src_p , & nh , nhe_id , table , metric , mtu ,
951- distance , tag , startup );
952961 } else {
953962 /* This is a multipath route */
954- struct route_entry * re ;
955- struct nexthop_group * ng = NULL ;
956963 struct rtnexthop * rtnh =
957964 (struct rtnexthop * )RTA_DATA (tb [RTA_MULTIPATH ]);
958965
959- re = zebra_rib_route_entry_new (vrf_id , proto , 0 , flags ,
960- nhe_id , table , metric ,
961- mtu , distance , tag );
962-
963966 if (!nhe_id ) {
964967 uint8_t nhop_num ;
965968
966969 /* Use temporary list of nexthops; parse
967970 * message payload's nexthops.
968971 */
969- ng = nexthop_group_new ();
970972 nhop_num =
971973 parse_multipath_nexthops_unicast (
972974 ns_id , ng , rtm , rtnh , tb ,
@@ -981,23 +983,22 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
981983 ng = NULL ;
982984 }
983985 }
984-
985- if (nhe_id || ng )
986- rib_add_multipath (afi , SAFI_UNICAST , & p ,
987- & src_p , re , ng , startup );
988- else {
989- /*
990- * I really don't see how this is possible
991- * but since we are testing for it let's
992- * let the end user know why the route
993- * that was just received was swallowed
994- * up and forgotten
995- */
996- zlog_err (
997- "%s: %pFX multipath RTM_NEWROUTE has a invalid nexthop group from the kernel" ,
998- __func__ , & p );
999- XFREE (MTYPE_RE , re );
1000- }
986+ }
987+ if (nhe_id || ng )
988+ rib_add_multipath (afi , SAFI_UNICAST , & p , & src_p , re , ng ,
989+ startup );
990+ else {
991+ /*
992+ * I really don't see how this is possible
993+ * but since we are testing for it let's
994+ * let the end user know why the route
995+ * that was just received was swallowed
996+ * up and forgotten
997+ */
998+ zlog_err (
999+ "%s: %pFX multipath RTM_NEWROUTE has a invalid nexthop group from the kernel" ,
1000+ __func__ , & p );
1001+ XFREE (MTYPE_RE , re );
10011002 }
10021003 } else {
10031004 if (nhe_id ) {
0 commit comments