seantywork

01


-------------------------
|                       |
|                       |
|    host network       |
|         veth01        |
|           |           |
|           |           |
------------|-------------
            |
            |
------------|---------------
|           |             |
|           |             |
|          veth02         |  
|    namespaced network   |
|                         |
|                         |
---------------------------


02


[Apr 6 05:18] entered xmit
[  +0.000010] entered hw tx
[  +0.000003] kxfrm: ipproto ESP
[  +0.000002] kxfrm: spi: 01000000
[  +0.000005] kxfrm: got xfrm state
[  +0.000001] kxfrm: totlen: 154: esplen: 96: payloadlen: 80
[  +0.000004] esp: spi: 01000000
[  +0.000003] esp: seq: 00000010
[  +0.000002] aalgname: hmac(sha256)
[  +0.000003] aalg key start: AABBCCDD
[  +0.000003] ealgname: cbc(aes)
[  +0.000002] ealg key start: AABBCCDD
[  +0.000002] kxfrm: got nonce
[  +0.000002] kxfrm: nonce: A6A34725
[  +0.000035] hmac: 582E5B00
[  +0.000002] calc hmac: 582E5B00
[  +0.000003] kxfrm: hmac verification success
[  +0.000010] kxfrm: decrypt success
[  +0.000002] decap ip src: 0aa84201
[  +0.000002] decap ip dst: 0aa84202
[  +0.000002] decap ip data len: 66
[  +0.000002] decap pad exists: 
[  +0.000001] ==========PAD START==========
[  +0.000002] 1
[  +0.000002] 2
[  +0.000002] 3
[  +0.000001] 4
[  +0.000002] 5
[  +0.000002] 6
[  +0.000001] 7
[  +0.000002] 8
[  +0.000001] 9
[  +0.000002] 10
[  +0.000002] 11
[  +0.000001] 12
[  +0.000002] ==========PAD END==========
[  +0.000002] total padlen: 12
[  +0.000002] next header: 4
[  +0.000002] decap ip padded data len: 80
[  +0.000001] dec ip proto tcp: dst port: 09999
[  +0.000003] 9999: data: \x01\x01\x08
              \x9a\x8c?t\x0e\x05/\xc2helloxfrm!!!!
              \x01\x02\x03\x04\x05\x06\x07\x08
              


              \x04
[  +0.000002] kxfrm: reencrpyted
[  +0.000002] kxfrm: reencrypted result match
[  +0.000007] kxfrm: hmac recalculated
[  +0.000002] kxfrm: copied generated values
[  +0.000001] kxfrm: old ipcsum: EDA0
[  +0.000002] kxfrm: new ipcsum: EDA0
[  +0.000002] kxfrm: success

03


# the moment you insert the kernel module
# using `insmod deth.ko`

# this function will initiate
# two ethernet interfaces
# and invokes...
deth_init_module
  |
  |         # ...this function
  |         # which sets up
  |         # data structures and
  |         # operations for each interface
  |         # and registers..
  --------> deth_setup
              |
              |  #... this function
              |  # which sets MAC address and
              |  # enable NAPI for RX
              --------> deth_open
              |
              |  #... and this function
              |  # which is used
              |  # to send packet to the other end
              --------> deth_xmit
                 # ... and few others


04


---------------------------
|                         |
|                         |
|    host network         |
|         deth1           |
|    (192.168.10.1/24)    |
|           |             |
|           |             |
------------|--------------
            |
            |
------------|--------------
|           |             |
|           |             |
|     (192.168.10.2/24)   |
|          deth2          |  
|    vnet network         |
|                         |
|                         |
---------------------------




05


# the moment you connect (or send)
# from your client on host to the server 
# on the vnet namespace,
# this function triggers...
deth_xmit
 |
 |  # ...this function
 |  # which prints eth src,dst
 |  # checks protocol,
 |  # prints ip src, dst
 |  # get the device pointer of the other end
 |  # and invokes...
 ---------> deth_hw_tx
             |
             | # ... this function 
             | # to get the tx slot of sender interface
             ----> deth_tx_cons_buffer
             | # ... this function
             | # to set the rx slot of receiver interface
             ----> deth_rx_prod_buffer
             | # ... this function
             | # to trigger the receiver interface
             | # to start napi polling (receiving)
             ----> deth_interrupt(deth_napi_interrupt)

# and here, this is what happens
# when deth_napi_interrupt is triggered
# this function, if real network interface card was used,
# will be triggerd as actual hardware irq is fired
# after registering using request_irq function.
# however, since there is no real nic involved in this scenario
# this function is manually triggered by calling deth_interrupt 
# within hw_tx
# this function invokes...
deth_napi_interrupt
 |
 | # ...this function if statusword is RX_INTR
 ----> napi_schedule

# and here, this is what happens
# when napi_schedule is triggered
# this function start...
napi_schedule
 |
 | # ...this function
 | # which is registered using netif_napi_add_weight
 | # within deth_setup
 | # this is the receiving logic 
 | # this invokes....
 ----> deth_poll
        |
        | # ... this function
        | # which gets the packet set within hw_tx
        ----> deth_rx_cons_buf
        |
        | # ... and this function
        | # which frees up the space for another
        | # transmission by the sending side
        ----> deth_tx_release_buffer