@@ -48,7 +48,6 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
4848 bool needs_id )
4949{
5050 DECLARE_BITMAP (id_bitmap , MPTCP_PM_MAX_ADDR_ID + 1 );
51- struct mptcp_pm_addr_entry * match = NULL ;
5251 struct sock * sk = (struct sock * )msk ;
5352 struct mptcp_pm_addr_entry * e ;
5453 bool addr_match = false;
@@ -63,16 +62,12 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
6362 if (addr_match && entry -> addr .id == 0 && needs_id )
6463 entry -> addr .id = e -> addr .id ;
6564 id_match = (e -> addr .id == entry -> addr .id );
66- if (addr_match && id_match ) {
67- match = e ;
65+ if (addr_match || id_match )
6866 break ;
69- } else if (addr_match || id_match ) {
70- break ;
71- }
7267 __set_bit (e -> addr .id , id_bitmap );
7368 }
7469
75- if (!match && ! addr_match && !id_match ) {
70+ if (!addr_match && !id_match ) {
7671 /* Memory for the entry is allocated from the
7772 * sock option buffer.
7873 */
@@ -90,7 +85,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
9085 list_add_tail_rcu (& e -> list , & msk -> pm .userspace_pm_local_addr_list );
9186 msk -> pm .local_addr_used ++ ;
9287 ret = e -> addr .id ;
93- } else if (match ) {
88+ } else if (addr_match && id_match ) {
9489 ret = entry -> addr .id ;
9590 }
9691
@@ -465,9 +460,7 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk,
465460 break ;
466461#if IS_ENABLED (CONFIG_MPTCP_IPV6 )
467462 case AF_INET6 : {
468- const struct ipv6_pinfo * pinfo = inet6_sk (ssk );
469-
470- if (!ipv6_addr_equal (& local -> addr6 , & pinfo -> saddr ) ||
463+ if (!ipv6_addr_equal (& local -> addr6 , & issk -> pinet6 -> saddr ) ||
471464 !ipv6_addr_equal (& remote -> addr6 , & ssk -> sk_v6_daddr ))
472465 continue ;
473466 break ;
@@ -641,7 +634,8 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
641634 struct mptcp_sock * msk ;
642635 int ret = - EINVAL ;
643636 struct sock * sk ;
644- void * hdr ;
637+
638+ BUILD_BUG_ON (sizeof (struct id_bitmap ) > sizeof (cb -> ctx ));
645639
646640 bitmap = (struct id_bitmap * )cb -> ctx ;
647641
@@ -657,19 +651,10 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
657651 if (test_bit (entry -> addr .id , bitmap -> map ))
658652 continue ;
659653
660- hdr = genlmsg_put (msg , NETLINK_CB (cb -> skb ).portid ,
661- cb -> nlh -> nlmsg_seq , & mptcp_genl_family ,
662- NLM_F_MULTI , MPTCP_PM_CMD_GET_ADDR );
663- if (!hdr )
654+ if (mptcp_pm_genl_fill_addr (msg , cb , entry ) < 0 )
664655 break ;
665656
666- if (mptcp_nl_fill_addr (msg , entry ) < 0 ) {
667- genlmsg_cancel (msg , hdr );
668- break ;
669- }
670-
671657 __set_bit (entry -> addr .id , bitmap -> map );
672- genlmsg_end (msg , hdr );
673658 }
674659 spin_unlock_bh (& msk -> pm .lock );
675660 release_sock (sk );
0 commit comments