{"id":227,"date":"2012-01-13T22:40:13","date_gmt":"2012-01-14T06:40:13","guid":{"rendered":"http:\/\/h2plus.biz\/hiromitsu\/?p=227"},"modified":"2018-08-06T13:31:39","modified_gmt":"2018-08-06T20:31:39","slug":"net_device%e6%a7%8b%e9%80%a0%e4%bd%93%e3%81%aeapi%e3%81%8c%e6%b6%88%e3%81%88%e3%81%a6%e3%81%84%e3%81%9f","status":"publish","type":"post","link":"https:\/\/h2plus.biz\/hiromitsu\/entry\/227","title":{"rendered":"net_device\u69cb\u9020\u4f53\u306eAPI\u304c\u6d88\u3048\u3066\u3044\u305f"},"content":{"rendered":"<p>\u4ed5\u4e8b\u3067\u958b\u767a\u3057\u3066\u3044\u308b\u7d44\u307f\u8fbc\u307f\u6a5f\u5668\u306eLinux\u30ab\u30fc\u30cd\u30eb\u3092\u30012.6.27\u7cfb\u304b\u30892.6.32\u7cfb\u306b\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3059\u308b\u305f\u3081\u306b\u3001\u4e45\u3005\u306b\u30ab\u30fc\u30cd\u30eb\u306e\u518d\u69cb\u7bc9\u306a\u3093\u304b\u3084\u3063\u3066\u3066\u3001\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30c7\u30d0\u30a4\u30b9\u306e\u30ea\u30f3\u30af\u72b6\u614b\u3092\u76e3\u8996\u3059\u308b\u305f\u3081\u306b\u81ea\u4f5c\u3057\u305fLKM\u304c\u3042\u3063\u305f\u306e\u3067\u30012.6.27.x\u3067\u4f7f\u3063\u3066\u3044\u305f\u3082\u306e\u3092\u305d\u306e\u307e\u307e2.6.32.x\u306b\u30b3\u30d4\u30fc\u3057\u3066\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u305f\u3089\u901a\u3089\u306a\u304b\u3063\u305forz<\/p>\n<pre>\nerror: \u2018struct net_device\u2019 has no member named \u2018get_stats\u2019\nerror: \u2018struct net_device\u2019 has no member named \u2018do_ioctl\u2019\n<\/pre>\n<p><code>net_device<\/code>\u69cb\u9020\u4f53\u304b\u3089<code>get_stats()<\/code>\u3068<code>do_ioctl()<\/code>\u304c\u306a\u304f\u306a\u3063\u305f\u3088\u3046\u3060\u3002<\/p>\n<p><!--more--><br \/>\n\u3068\u308a\u3042\u3048\u305a\u3001\u3069\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u30ab\u30fc\u30cd\u30ebAPI\u304c\u5909\u66f4\u3055\u308c\u305f\u306e\u304b\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u3001git.kernel.org\u304b\u3089\u30bd\u30fc\u30b9\u30c4\u30ea\u30fc\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u304a\u304f\u3002<\/p>\n<pre>\n$ git clone git:\/\/git.kernel.org\/pub\/scm\/linux\/kernel\/git\/stable\/linux-stable.git\n<\/pre>\n<p><code>net_device<\/code>\u69cb\u9020\u4f53\u306f<code>include\/linux\/netdevice.h<\/code>\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001<code>git diff<\/code>\u3092\u898b\u306a\u304c\u3089<code>get_stats()<\/code>\u3068<code>do_ioctl()<\/code>\u304c\u6d88\u3048\u305f\u30d6\u30e9\u30f3\u30c1\u3092\u63a2\u3057\u3066\u3044\u304f\u3002<\/p>\n<pre>\n$ cd linux-stable\/include\/linux\n$ git diff v2.6.27.59 v2.6.32.1 netdevice.h\n$ git diff v2.6.27.59 v2.6.31.1 netdevice.h\n$ git diff v2.6.27.59 v2.6.30.1 netdevice.h\n<\/pre>\n<p>\u3069\u3046\u3084\u3089v2.6.27\u7cfb\u304b\u3089v2.6.30\u7cfb\u306b\u79fb\u308b\u3068\u304d\u306b\u6d88\u3048\u305f\u3088\u3046\u3060\u3002<\/p>\n<p><code>get_stats()<\/code>\u306b\u95a2\u3057\u3066\u306f<code>dev_get_stats()<\/code>\u3068\u3044\u3046\u30b0\u30ed\u30fc\u30d0\u30eb\u95a2\u6570\u306b\u7f6e\u304d\u63db\u308f\u3063\u305f\u3089\u3057\u304f\u3001<a href=\"https:\/\/git.kernel.org\/?p=linux\/kernel\/git\/stable\/linux-stable.git;a=commitdiff;h=eeda3fd64f75bcbfaa70ce946513abaf3f23b8e0\"><code>netdev: Introduce dev_get_stats()<\/code><\/a>\u3068\u3044\u3046\u30b3\u30df\u30c3\u30c8\u30ed\u30b0\u304c\u898b\u3064\u304b\u3063\u305f\u3002<\/p>\n<p>v2.6.27\u7cfb\u3068\u306e\u4e92\u63db\u6027\u3092\u4fdd\u3064\u305f\u3081\u3001<code>get_stats()<\/code>\u3092\u30e9\u30c3\u30d7\u3059\u308b\u95a2\u6570\u3092\u8ffd\u52a0\u3057\u3066\u89e3\u6c7a\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nstatic const struct net_device_stats *compat_get_stats(struct net_device *dev)\r\n{\r\n#if LINUX_VERSION_CODE &amp;lt; KERNEL_VERSION(2,6,30)\r\n    return dev-&amp;gt;get_stats ? dev-&amp;gt;get_stats(dev) : NULL;\r\n#else\r\n    return dev_get_stats(dev);\r\n#endif\r\n}\r\n<\/pre>\n<p><code>do_ioctl()<\/code>\u306f\u3001v2.6.30\u304b\u3089\u767b\u5834\u3057\u305f<code>net_device_ops<\/code>\u69cb\u9020\u4f53\u306b\u3042\u308b<code>ndo_do_ioctl()<\/code>\u304c\u4ee3\u66ffAPI\u306e\u3088\u3046\u306b\u601d\u3048\u308b\u3002\u30ab\u30fc\u30cd\u30eb\u30bd\u30fc\u30b9\u30c4\u30ea\u30fc\u3092<code>grep<\/code>\u3057\u3066\u3001v2.6.27\u7cfb\u3067<code>do_ioctl()<\/code>\u3092\u4f7f\u3063\u3066\u3044\u305f\u30e2\u30b8\u30e5\u30fc\u30eb\u304cv2.6.30\u7cfb\u3067\u3069\u3046\u4fee\u6b63\u3055\u308c\u305f\u304b\u63a2\u3057\u305f\u3089\u3001<code>net\/wireless\/wext.c<\/code>\u306b\u884c\u304d\u7740\u3044\u305f\u3002<\/p>\n<pre class=\"brush: diff; title: ; notranslate\" title=\"\">\r\n@@ -1055,8 +1062,8 @@ static int wireless_process_ioctl(struct net *net, struct \r\n                        return private(dev, iwr, cmd, info, handler);\r\n        }\r\n        \/* Old driver API : call driver ioctl handler *\/\r\n-       if (dev-&amp;gt;do_ioctl)\r\n-               return dev-&amp;gt;do_ioctl(dev, ifr, cmd);\r\n+       if (dev-&amp;gt;netdev_ops-&amp;gt;ndo_do_ioctl)\r\n+               return dev-&amp;gt;netdev_ops-&amp;gt;ndo_do_ioctl(dev, ifr, cmd);\r\n        return -EOPNOTSUPP;\r\n }\r\n<\/pre>\n<p><code>get_stats()<\/code>\u3068\u540c\u69d8\u306b\u3001<code>do_ioctl()<\/code>\u3092\u30e9\u30c3\u30d7\u3059\u308b\u95a2\u6570\u3092\u8ffd\u52a0\u3057\u3066\u89e3\u6c7a\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nstatic int compat_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)\r\n{\r\n#if LINUX_VERSION_CODE &amp;lt; KERNEL_VERSION(2,6,30)\r\n    return dev-&amp;gt;do_ioctl(dev, ifr, cmd);\r\n#else\r\n    return dev-&amp;gt;netdev_ops-&amp;gt;ndo_do_ioctl(dev, ifr, cmd);\r\n#endif\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4ed5\u4e8b\u3067\u958b\u767a\u3057\u3066\u3044\u308b\u7d44\u307f\u8fbc\u307f\u6a5f\u5668\u306eLinux\u30ab\u30fc\u30cd\u30eb\u3092\u30012.6.27\u7cfb\u304b\u30892.6.32\u7cfb\u306b\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3059\u308b\u305f\u3081\u306b\u3001\u4e45\u3005\u306b\u30ab\u30fc\u30cd\u30eb\u306e\u518d\u69cb\u7bc9\u306a\u3093\u304b\u3084\u3063\u3066\u3066\u3001\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30c7\u30d0\u30a4\u30b9\u306e\u30ea\u30f3\u30af\u72b6\u614b\u3092\u76e3\u8996\u3059\u308b\u305f\u3081\u306b\u81ea\u4f5c\u3057\u305fLKM\u304c\u3042\u3063\u305f <a href='https:\/\/h2plus.biz\/hiromitsu\/entry\/227' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[115,84],"tags":[121,122,120,126,127,125,124,116,123,118,119,117],"_links":{"self":[{"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/posts\/227"}],"collection":[{"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/comments?post=227"}],"version-history":[{"count":1,"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/posts\/227\/revisions"}],"predecessor-version":[{"id":938,"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/posts\/227\/revisions\/938"}],"wp:attachment":[{"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/media?parent=227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/categories?post=227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/tags?post=227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}