Skip to contentSkip to conversation

sctp: add pf_expose per netns and sock and asoc

PATCH Xin Long 1 participant 1 message Sep 10, 2019 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 201909091802.pU2vj2DA%[email protected]

A message that is not in the archive (sent off-list or not yet received): 20190910035421.GB1778@archlinux-threadripper

Xin Long

author maintainer
#2 lore raw
Quoted 72 lines · Nathan Chancellor

Hi Xin,

The 0day team has been doing clang builds for us and this warning popped up. Let me know if you have any questions.

Quoted 55 lines · kbuild test robot

CC: [email protected]
In-Reply-To: <00fb06e74d8eedeb033dad83de18380bf6261231.1568015756.git.lucien.xin@gmail.com>
References: <00fb06e74d8eedeb033dad83de18380bf6261231.1568015756.git.lucien.xin@gmail.com>
TO: Xin Long <[email protected]>
CC: network dev <[email protected]>, [email protected]
CC: Marcelo Ricardo Leitner <[email protected]>, Neil Horman <[email protected]>, [email protected]

Hi Xin,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url: https://github.com/0day-ci/linux/commits/Xin-Long/sctp-update-from-rfc7829/20190909-160115
config: x86_64-rhel-7.6 (attached as .config)
compiler: clang version 10.0.0 (git://gitmirror/llvm_project 45a3fd206fb06f77a08968c99a8172cbf2ccdd0f) reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64

If you fix the issue, kindly add following tag

All warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

net/sctp/associola.c:799:24: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]

                   if (transport->state && SCTP_UNCONFIRMED &&
                                        ^  ~~~~~~~~~~~~~~~~
   net/sctp/associola.c:799:24: note: use '&' for a bitwise operation
                   if (transport->state && SCTP_UNCONFIRMED &&
                                        ^~
                                        &
   net/sctp/associola.c:799:24: note: remove constant to silence this warning
                   if (transport->state && SCTP_UNCONFIRMED &&
                                       ~^~~~~~~~~~~~~~~~~~~

1 warning generated.

vim +799 net/sctp/associola.c

775
776 /* Engage in transport control operations.

   777         * Mark the transport up or down and send a notification to the user.
   778         * Select and update the new active and retran paths.
   779         */
   780        void sctp_assoc_control_transport(struct sctp_association *asoc,
   781                                          struct sctp_transport *transport,
   782                                          enum sctp_transport_cmd command,
   783                                          sctp_sn_error_t error)
   784        {
   785                struct sctp_ulpevent *event;
   786                struct sockaddr_storage addr;
   787                int spc_state = 0;
   788                bool ulp_notify = true;
   789
   790                /* Record the transition on the transport.  */
Quoted 9 lines
   791                switch (command) {
   792                case SCTP_TRANSPORT_UP:
   793                        /* If we are moving from UNCONFIRMED state due
   794                         * to heartbeat success, report the SCTP_ADDR_CONFIRMED
   795                         * state to the user, otherwise report SCTP_ADDR_AVAILABLE.
   796                         */
   797                        if (transport->state = SCTP_PF && !asoc->pf_expose)
   798                                ulp_notify = false;
Quoted 1 line

799 if (transport->state && SCTP_UNCONFIRMED &&

Quoted 1 line

I assume this && should either be a '&' or '='?

Right, it should have been "=". It was changed unintentionally when I swapped the position of 'state' and 'SCTP_UNCONFIRMED'.

Thanks, will post v2 after others' review.

Quoted 59 lines
Quoted 53 lines
   800                            SCTP_HEARTBEAT_SUCCESS = error)
   801                                spc_state = SCTP_ADDR_CONFIRMED;
   802                        else
   803                                spc_state = SCTP_ADDR_AVAILABLE;
   804                        transport->state = SCTP_ACTIVE;
   805                        break;
   806
   807                case SCTP_TRANSPORT_DOWN:
   808                        /* If the transport was never confirmed, do not transition it
   809                         * to inactive state.  Also, release the cached route since
   810                         * there may be a better route next time.
   811                         */
   812                        if (transport->state != SCTP_UNCONFIRMED) {
   813                                transport->state = SCTP_INACTIVE;
   814                                spc_state = SCTP_ADDR_UNREACHABLE;
   815                        } else {
   816                                sctp_transport_dst_release(transport);
   817                                ulp_notify = false;
   818                        }
   819                        break;
   820
   821                case SCTP_TRANSPORT_PF:
   822                        transport->state = SCTP_PF;
   823                        if (!asoc->pf_expose)
   824                                ulp_notify = false;
   825                        else
   826                                spc_state = SCTP_ADDR_POTENTIALLY_FAILED;
   827                        break;
   828
   829                default:
   830                        return;
   831                }
   832
   833                /* Generate and send a SCTP_PEER_ADDR_CHANGE notification
   834                 * to the user.
   835                 */
   836                if (ulp_notify) {
   837                        memset(&addr, 0, sizeof(struct sockaddr_storage));
   838                        memcpy(&addr, &transport->ipaddr,
   839                               transport->af_specific->sockaddr_len);
   840
   841                        event = sctp_ulpevent_make_peer_addr_change(asoc, &addr,
   842                                                0, spc_state, error, GFP_ATOMIC);
   843                        if (event)
   844                                asoc->stream.si->enqueue_event(&asoc->ulpq, event);
   845                }
   846
   847                /* Select new active and retran paths. */
   848                sctp_select_active_and_retran_path(asoc);
   849        }
   850
Quoted 3 lines

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Cheers,
Nathan