我正在尝试交叉编译Openvswitch for android。 我按照https://docs.google.com/document/pub?id=1k5jAkz_R475Ohj0OaJdWwSpAw6mmR2Mp_Ggr8_yrXsY的说明进行操作。
内核版本
我已按照https://source.android.com/source/building-kernels.html的说明成功下载并构建了Galaxy nexus的omap内核。 内核位于我的桌面/ home / zoe / AOSP / omap文件夹中。内核是3.0.72版本。
我已经下载了Android NDK r5b,以便使用工具链arm-eabi-4.4.0中的交叉编译器。
OpenVswitch版本
我尝试了很多版本。 1.7.0,1.9.3,2.0.0,但所有这些都给了我同样的错误(openvswitch.ko undefined!)。
初始化环境
首先,我运行以下命令
export ANDROID_NDK_ROOT=/home/zoe/android-ndk-r5b
export ANDROID_KERNEL=/home/zoe/AOSP/omap
然后我设置PATH,以便可以找到交叉编译器:
export PATH=$PATH:/home/zoe/android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin
cd openvswitch-2.0.0
然后我生成配置文件:
./boot.sh
然后,我运行configure:
./configure --host=arm-eabi CC=arm-eabi-gcc CPPFLAGS="-I$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/include/" CFLAGS="-nostdlib" LDFLAGS="-Wl,-rpath-link=$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/ -L$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/" LIBS="-lc " ovs_cv_use_linker_sections=no --with-l26=$ANDROID_KERNEL KARCH=arm --with-rundir=/data/local/var
当我在openvswitch文件夹中ARCH=arm CROSS_COMPILE=arm-eabi- make
时,在构建模块阶段2,我收到许多错误和警告,说明openvswitch.ko未定义:
错误消息
Building modules, stage 2.
MODPOST 1 modules
WARNING: "register_netdevice" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kmem_cache_destroy" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kmalloc_caches" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__kmalloc" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_gso_segment" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "register_pernet_device" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_unlock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "del_timer" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "strlen" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "rcu_barrier" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "genl_unregister_family" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "autoremove_wake_function" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "ip_local_out" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "get_random_bytes" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "netdev_rx_handler_register" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "rtnl_lock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_copy_and_csum_dev" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "dst_release" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_lock_bh" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_clone" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "dev_get_by_name" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_find_next_bit_le" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "register_netdevice_notifier" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__alloc_percpu" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "inet_proto_csum_replace4" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "sock_create_kern" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "mutex_unlock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "call_rcu" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "crc32c" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kthread_create_on_node" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "jiffies" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "free_percpu" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "unregister_netdevice_notifier" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_trim" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "strcmp" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "netif_rx" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__pskb_pull_tail" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__init_waitqueue_head" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nr_cpu_ids" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nla_memcpy" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "wait_for_completion" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__memzero" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nlmsg_notify" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "memset" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "net_namespace_list" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_checksum" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "random32" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_unlock_irqrestore" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "jiffies_to_msecs" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "printk" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "ethtool_op_get_link" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kthread_stop" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "memcmp" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "unregister_pernet_device" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "ipv6_ext_hdr" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__skb_warn_lro_forwarding" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nla_find" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "free_netdev" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "strncpy" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nla_put" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_unlock_irq" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "strlcpy" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kmem_cache_free" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "warn_slowpath_null" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_push" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "mutex_lock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "dev_get_by_index_rcu" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__skb_get_rxhash" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "sk_free" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "netlink_unicast" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__rcu_read_unlock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "add_timer" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "genl_register_family_with_ops" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_pull" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "init_net" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "flex_array_get" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "ksize" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__do_div64" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "boot_tvec_bases" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "local_bh_disable" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__secpath_destroy" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kmem_cache_alloc" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__nla_reserve" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__alloc_skb" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "sk_release_kernel" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "netlink_broadcast" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_unlock_bh" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nla_parse" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "cpu_possible_mask" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "netdev_rx_handler_unregister" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_checksum_help" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "schedule" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kfree_skb" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_lock_irq" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "local_bh_enable" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "alloc_netdev_mqs" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "eth_type_trans" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__bug" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "wake_up_process" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "pskb_expand_head" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "ether_setup" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kmem_cache_alloc_trace" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_lock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__per_cpu_offset" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_lock_irqsave" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nf_conntrack_destroy" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_pull_rcsum" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kmem_cache_create" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "unregister_netdevice_queue" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "ip_route_output_flow" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "ktime_get_ts" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__wake_up" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "net_ratelimit" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "netlink_set_err" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "flex_array_free" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kthread_should_stop" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "dev_set_promiscuity" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kfree" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "memcpy" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "prepare_to_wait" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kernel_bind" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "genl_register_mc_group" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "flex_array_alloc" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "finish_wait" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_set_bit" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nla_reserve" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "complete" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_test_and_set_bit" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "memmove" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "csum_partial" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "consume_skb" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "dev_queue_xmit" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__rcu_read_lock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_clear_bit" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_put" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_copy_bits" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "inet_get_local_port_range" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "rtnl_unlock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__ip_select_ident" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__nla_put" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "flex_array_prealloc" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
CC /home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.o
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:8: error: variable '__this_module' has initializer but incomplete type
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:9: error: unknown field 'name' specified in initializer
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:9: warning: excess elements in struct initializer
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:9: warning: (near initialization for '__this_module')
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:10: error: unknown field 'init' specified in initializer
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:10: warning: excess elements in struct initializer
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:10: warning: (near initialization for '__this_module')
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:14: error: unknown field 'arch' specified in initializer
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:14: error: 'MODULE_ARCH_INIT' undeclared here (not in a function)
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:14: warning: excess elements in struct initializer
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:14: warning: (near initialization for '__this_module')
make[5]: *** [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.o] Error 1
make[4]: *** [modules] Error 2
make[4]: Leaving directory `/home/zoe/AOSP/omap'
make[3]: *** [default] Error 2
make[3]: Leaving directory `/home/zoe/openvswitch-2.0.0/datapath/linux'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/zoe/openvswitch-2.0.0/datapath'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/zoe/openvswitch-2.0.0'
make: *** [all] Error 2
我无法理解出了什么问题。我无法在网络上找到解决方案。
感谢。
答案 0 :(得分:0)
过去几天我一直在尝试针对Android KitKat编译ovs内核模式。最后,我做了许多试验和错误。我遇到了你的问题,并希望我的解决方案可以帮助其他需要补救的人,尽管这篇文章已经过时了。
基本上,你的ovs编译中的主要错误是' __ this_module'找不到。在线找到的常见解决方案(在Android内核目录中启用.config中的LOADABLE_MODULES = y)对于此问题无效。原因是ovs在配置和运行 make 时并不是指.config文件。 启用' LOADABLE_MODULES'后,您需要首先使用您的ndk或Android工具链来编译Android内核,以使新配置生效。然后您可以编译您的ov, ' __ THIS_MODULE'错误将消失。