[rds-devel] make some extension to ping message.

Tang, Changqing changquing.tang at hp.com
Tue Apr 20 09:40:32 PDT 2010

Hi, Tina,
        I try to add extension to the "ping" function in RDS (where the destination port number is 0).  If the ping message also has some playload, they are my conext (64bits) and process port (16bits).
        When a pong message is sent back (rds_send_pong()), and the ping message has payload,
I do the following:
        1. alloc space for the pong message payload (10 bytes).
        2. get the ping message payload 'context' and 'dport'.
        3. check if the process 'dport' exists by rds_find_bound(), if not, set 'dport=0'.
        4. set 'context' and new 'dport' in the new pong message as payload.

The new rds_send_pong() is asfollowing (it only works for IB transport):

 * Reply to a ping packet.
rds_send_pong(struct rds_connection *conn, struct rds_incoming *inc)
        struct rds_message *rm;
        unsigned long flags;
        int ret = 0;
        u32 len;
        struct rds_ib_incoming *ibinc;
        struct rds_page_frag *frag;
        char    *addr;
        u64     context;
        __be16  dport;
        struct rds_sock *rs = NULL;

        len = be32_to_cpu(inc->i_hdr.h_len);

        rm = rds_message_alloc(len?1:0, GFP_ATOMIC);
        if (rm == NULL) {
                ret = -ENOMEM;
                goto out;

        rm->m_daddr = conn->c_faddr;

        if (len) {
                ibinc = container_of(inc, struct rds_ib_incoming, ii_inc);
                frag = list_entry(ibinc->ii_frags.next,
                                struct rds_page_frag, f_item);
                addr = (char*)kmap_atomic(frag->f_page, KM_USER0);
                context = *(u64*)(addr+frag->f_offset);
                dport = *(__be16*)(addr+frag->f_offset+8);
                kunmap_atomic(addr, KM_USER0);

                rs = rds_find_bound(conn->c_laddr, cpu_to_be16(dport));
                if (rs == NULL) {
                        dport = 0;
                } else {

                rm->m_inc.i_hdr.h_len = cpu_to_be32(10);
                ret = rds_page_remainder_alloc(rm->m_sg, 10, GFP_HIGHUSER);
                if (ret) goto out;
                addr = (char*)kmap_atomic(sg_page(rm->m_sg), KM_USER0);
                *(u64*)(addr+rm->m_sg->offset) = context;
                *(__be16*)(addr+rm->m_sg->offset+8) = dport;
                kunmap_atomic(addr, KM_USER0);

        /* If the connection is down, trigger a connect. We may
         * have scheduled a delayed reconnect however - in this case

However, I got the following kernel dump backtrace:

crash> bt
PID: 3189   TASK: ffff81042fa360c0  CPU: 0   COMMAND: "krdsd/0"
 #0 [ffff81041a82da80] crash_kexec at ffffffff800ac059
 #1 [ffff81041a82db40] __die at ffffffff80066245
 #2 [ffff81041a82db80] do_page_fault at ffffffff80067e57
 #3 [ffff81041a82dc70] error_exit at ffffffff8005ede9
    [exception RIP: rds_ib_xmit+2036]
    RIP: ffffffff886b5988  RSP: ffff81041a82dd20  RFLAGS: 00010246
    RAX: ffff810418729cc0  RBX: 0000000000000003  RCX: 0000000000000000
    RDX: 0000000000000003  RSI: 0000000000000000  RDI: ffff810420cf8400
    RBP: ffff810420cf8400   R8: 0000000000000003   R9: 0000000000000004
    R10: ffff810411aca000  R11: ffffffff80013fa7  R12: ffff810418729cc0
    R13: 0000000000000000  R14: ffffc200009b22e8  R15: 0000000000000100
    ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
 #4 [ffff81041a82ddc8] rds_send_xmit at ffffffff8868e187
 #5 [ffff81041a82de28] rds_send_worker at ffffffff8868e84c
 #6 [ffff81041a82de38] run_workqueue at ffffffff8004dcda
 #7 [ffff81041a82de78] worker_thread at ffffffff8004a645
 #8 [ffff81041a82dee8] kthread at ffffffff80032e41
 #9 [ffff81041a82df48] kernel_thread at ffffffff8005efb1

Would you please help find the error in my code above?

Thank you very much.

More information about the rds-devel mailing list