ipip学习记录-凯发app官方网站

凯发app官方网站-凯发k8官网下载客户端中心 | | 凯发app官方网站-凯发k8官网下载客户端中心
  • 博客访问: 413381
  • 博文数量: 124
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 872
  • 用 户 组: 普通用户
  • 注册时间: 2018-03-29 14:38
个人简介

默默的一块石头

文章分类

全部博文(124)

文章存档

2022年(26)

2021年(10)

2020年(28)

2019年(60)

我的朋友
相关博文
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·

分类: linux

2022-07-05 16:51:49

实验环境:ubuntu 18.04 linux:5.4.1
ipip实验环境设定:
ipip.sh
ip netns add ns1
ip netns add ns2

ip link add v1 type veth peer name v1_r
ip link add v2 type veth peer name v2_r

ip link set v1 netns ns1
ip link set v2 netns ns2

ip a a 10.10.10.1/24 dev v1_r
ip l s v1_r up
ip a a 10.10.20.1/24 dev v2_r
ip l s v2_r up

ip netns exec ns1 ip a a 10.10.10.2/24 dev v1
ip netns exec ns1 ip l s v1 up
ip netns exec ns2 ip a a 10.10.20.2/24 dev v2
ip netns exec ns2 ip l s v2 up

ip netns exec ns1 route add -net 10.10.20.0 netmask 255.255.255.0 gw 10.10.10.1
ip netns exec ns2 route add -net 10.10.10.0 netmask 255.255.255.0 gw 10.10.20.1

ip netns exec ns1 ip tunnel add tun1 mode ipip remote 10.10.20.2 local 10.10.10.2

ip netns exec ns1 ip l s tun1 up
ip netns exec ns1 ip a a 10.10.100.10 peer 10.10.200.10 dev tun1

ip netns exec ns2 ip tunnel add tun2 mode ipip remote 10.10.10.2 local 10.10.20.2

ip netns exec ns2 ip l s tun2 up
ip netns exec ns2 ip a a 10.10.200.10 peer 10.10.100.10 dev tun2

ip netns exec ns1 ping 10.10.200.10 -c 4

ipip xmit:
static const struct net_device_ops ipip_netdev_ops = {
.ndo_start_xmit= ipip_tunnel_xmit,
};

/*
 *this function assumes it is being called from dev_queue_xmit()
 *and that skb is filled properly by that function.
 */
static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb,
    struct net_device *dev)
{
struct ip_tunnel *tunnel = netdev_priv(dev);
const struct iphdr  *tiph = &tunnel->parms.iph;
u8 ipproto;

......
if (tunnel->collect_md)
ip_md_tunnel_xmit(skb, dev, ipproto, 0);
else
ip_tunnel_xmit(skb, dev, tiph, ipproto);
return netdev_tx_ok;
}

void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
    const struct iphdr *tnl_params, u8 protocol)
{
dst = tnl_params->daddr;
ip_tunnel_init_flow(&fl4, protocol, dst, tnl_params->saddr,
    tunnel->parms.o_key, rt_tos(tos), tunnel->parms.link,
    tunnel->fwmark, skb_get_hash(skb));
......
if (!rt) {
rt = ip_route_output_key(tunnel->net, &fl4);
......
}
......
iptunnel_xmit(null, rt, skb, fl4.saddr, fl4.daddr, protocol, tos, ttl,
      df, !net_eq(tunnel->net, dev_net(dev)));
return;
}

void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
   __be32 src, __be32 dst, __u8 proto,
   __u8 tos, __u8 ttl, __be16 df, bool xnet)
{
......
iph->daddr=dst;
iph->saddr=src;
......
err = ip_local_out(net, sk, skb);
......
}

jul  5 15:22:12 chro kernel: [   60.166102] cpu: 14 pid: 4703 comm: ping not tainted 5.4.1 #92
jul  5 15:22:12 chro kernel: [   60.166104] hardware name: machenike f117-x/x15cn, bios 008.t14 01/26/2021
jul  5 15:22:12 chro kernel: [   60.166105] call trace:
jul  5 15:22:12 chro kernel: [   60.166108]  dump_stack 0x6d/0x95
jul  5 15:22:12 chro kernel: [   60.166115]  ipip_tunnel_xmit 0x47/0x160 [ipip]
jul  5 15:22:12 chro kernel: [   60.166120]  dev_hard_start_xmit 0x96/0x200
jul  5 15:22:12 chro kernel: [   60.166124]  ? vprintk_emit 0x80/0x2d0
jul  5 15:22:12 chro kernel: [   60.166128]  __dev_queue_xmit 0x775/0xa10
jul  5 15:22:12 chro kernel: [   60.166130]  ? vprintk_default 0x29/0x50
jul  5 15:22:12 chro kernel: [   60.166133]  ? vprintk_func 0x47/0xc0
jul  5 15:22:12 chro kernel: [   60.166137]  dev_queue_xmit 0x10/0x20
jul  5 15:22:12 chro kernel: [   60.166140]  ? dev_queue_xmit 0x10/0x20
jul  5 15:22:12 chro kernel: [   60.166144]  neigh_direct_output 0x11/0x20
jul  5 15:22:12 chro kernel: [   60.166147]  ip_finish_output2 0x1fe/0x8a0
jul  5 15:22:12 chro kernel: [   60.166150]  __ip_finish_output 0xfa/0x1c0
jul  5 15:22:12 chro kernel: [   60.166152]  ? __ip_finish_output 0xfa/0x1c0
jul  5 15:22:12 chro kernel: [   60.166155]  ip_finish_output 0x2c/0xa0
jul  5 15:22:12 chro kernel: [   60.166158]  ip_output 0x6d/0xe0
jul  5 15:22:12 chro kernel: [   60.166161]  ? __ip_finish_output 0x1c0/0x1c0
jul  5 15:22:12 chro kernel: [   60.166164]  ip_local_out 0x3b/0x50
jul  5 15:22:12 chro kernel: [   60.166167]  ip_send_skb 0x19/0x40
jul  5 15:22:12 chro kernel: [   60.166170]  ip_push_pending_frames 0x33/0x40
jul  5 15:22:12 chro kernel: [   60.166175]  raw_sendmsg 0x9e5/0xcc0
jul  5 15:22:12 chro kernel: [   60.166179]  ? ttwu_do_wakeup 0x1e/0x150
jul  5 15:22:12 chro kernel: [   60.166185]  ? regulator_unregister 0x78/0xe0
jul  5 15:22:12 chro kernel: [   60.166189]  ? _cond_resched 0x19/0x40
jul  5 15:22:12 chro kernel: [   60.166192]  ? aa_sk_perm 0x43/0x190
jul  5 15:22:12 chro kernel: [   60.166197]  inet_sendmsg 0x64/0x70
jul  5 15:22:12 chro kernel: [   60.166201]  ? inet_sendmsg 0x64/0x70
jul  5 15:22:12 chro kernel: [   60.166205]  sock_sendmsg 0x5c/0x70
jul  5 15:22:12 chro kernel: [   60.166210]  __sys_sendto 0x13f/0x180
jul  5 15:22:12 chro kernel: [   60.166215]  ? ktime_get_ts64 0x51/0xf0
jul  5 15:22:12 chro kernel: [   60.166221]  __x64_sys_sendto 0x28/0x30
jul  5 15:22:12 chro kernel: [   60.166226]  do_syscall_64 0x57/0x190
jul  5 15:22:12 chro kernel: [   60.166231]  entry_syscall_64_after_hwframe 0x44/0xa9

阅读(645) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
")); function link(t){ var href= $(t).attr('href'); href ="?url=" encodeuricomponent(location.href); $(t).attr('href',href); //setcookie("returnouturl", location.href, 60, "/"); }
网站地图