diff options
| author | Qiuwen Lu <[email protected]> | 2017-03-22 14:41:35 +0800 |
|---|---|---|
| committer | Qiuwen Lu <[email protected]> | 2017-03-22 14:41:35 +0800 |
| commit | 83de81b8f4b4fe4faabc23517efa791430f65ac2 (patch) | |
| tree | 38f628e646ab9067bcdaa66453ca0b3170fbc439 /app/src/sendpath.c | |
| parent | 6e1fe7e6803a50f9a432c489f4d1c3356fce8e9e (diff) | |
增加线程绑定功能。修正虚设备销毁部分实现。修正数据面处理流程的Bug。
Diffstat (limited to 'app/src/sendpath.c')
| -rw-r--r-- | app/src/sendpath.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/app/src/sendpath.c b/app/src/sendpath.c index 0cf2b2c..06dfd5b 100644 --- a/app/src/sendpath.c +++ b/app/src/sendpath.c @@ -13,12 +13,12 @@ static inline int is_same_subnet(struct in_addr a_addr, struct in_addr b_addr, s return (in_addr_a & in_addr_mask) == (in_addr_b && in_addr_mask); } -static int droute_l2_construct_fn(struct mr_sendpath * sendpath, +static int droute_l2_construct_fn(struct mr_sendpath * sendpath, struct rte_mbuf * mbuf[], unsigned int nr_mbuf) { for (int i = 0; i < nr_mbuf; i++) { - struct ether_hdr * ether_hdr = (struct ether_hdr *)rte_pktmbuf_prepend(mbuf[i], + struct ether_hdr * ether_hdr = (struct ether_hdr *)rte_pktmbuf_prepend(mbuf[i], sizeof(struct ether_hdr)); MR_VERIFY_2(ether_hdr != NULL, "Not enough space for ethernet header in mbufs. "); @@ -46,19 +46,19 @@ static int droute_l3_construct_fn(struct mr_sendpath * sendpath, static int droute_requery(struct mr_sendpath * sendpath) { struct mr_instance * instance = sendpath->instance; - int ret = neigh_query(instance->neigh, sendpath->target_addr, + int ret = neigh_query(instance->neigh, sendpath->target_addr, &sendpath->dst_eth_addr, &sendpath->target_vdi); if (ret < 0) { - neigh_create_or_update(instance->neigh, sendpath->target_addr, + neigh_create_or_update(instance->neigh, sendpath->target_addr, NULL, sendpath->target_vdi, 0); } - + return 0; } -struct mr_sendpath * mr_sendpath_create_by_droute(struct mr_vdev * dest_device, struct in_addr addr) +struct mr_sendpath * marsio_sendpath_create_by_droute(struct mr_vdev * dest_device, struct in_addr addr) { struct vdev * vdev = dest_device->vdi->vdev; struct in_addr target_in_addr; @@ -72,7 +72,7 @@ struct mr_sendpath * mr_sendpath_create_by_droute(struct mr_vdev * dest_device, { target_in_addr = vdev->in_gateway; } - + struct mr_sendpath * sendpath = malloc(sizeof(struct mr_sendpath)); MR_VERIFY_MALLOC(sendpath); @@ -84,15 +84,15 @@ struct mr_sendpath * mr_sendpath_create_by_droute(struct mr_vdev * dest_device, sendpath->fn_l4_construct = NULL; sendpath->src_addr = vdev->in_addr; sendpath->dst_addr = addr; - + /* 查ARP表 */ - int ret = neigh_query(dest_device->instance->neigh, target_in_addr, + int ret = neigh_query(dest_device->instance->neigh, target_in_addr, &sendpath->dst_eth_addr, &sendpath->target_vdi); /* 没有查询成功,保存起来下一次再查 */ if (ret < 0) { - neigh_create_or_update(dest_device->instance->neigh, + neigh_create_or_update(dest_device->instance->neigh, target_in_addr, NULL, dest_device->vdi, 0); sendpath->can_use = 0; @@ -104,4 +104,15 @@ struct mr_sendpath * mr_sendpath_create_by_droute(struct mr_vdev * dest_device, } return sendpath; +} + +struct mr_sendpath * marsio_sendpath_create_by_vdev(struct mr_vdev * dest_device) +{ + struct mr_sendpath * sendpath = malloc(sizeof(struct mr_sendpath)); + MR_VERIFY_MALLOC(sendpath); + memset(sendpath, 0, sizeof(struct mr_sendpath)); + + sendpath->target_vdi = dest_device->vdi; + sendpath->can_use = 1; + return sendpath; }
\ No newline at end of file |
