<div dir="ltr"><div>On 12/26 10:53, Harsha Sharma wrote:</div><div>> On Tue, Dec 26, 2017 at 9:49 AM, Chen Jingpiao <<a href="mailto:chenjingpiao@gmail.com">chenjingpiao@gmail.com</a>> wrote:</div><div>> > On 12/25 10:26, Harsha Sharma wrote:</div><div>> >> On Mon, Dec 25, 2017 at 6:51 PM, JingPiao Chen <<a href="mailto:chenjingpiao@gmail.com">chenjingpiao@gmail.com</a>> wrote:</div><div>> >> > On 12/25 06:12, Harsha Sharma wrote:</div><div>> >> >> Hello everyone,</div><div>> >> ></div><div>> >> > Hi.</div><div>> >> ></div><div>> >> >> I'm Harsha Sharma, a sophomore student at Indian Institute of</div><div>> >> >> Technology,  Roorkee, India.</div><div>> >> >> I have knowledge of C, git, shell programming, kernel programming, gdb</div><div>> >> >> and parsers and currently working as outreachy intern in Linux-kernel</div><div>> >> >> (project nftables - Network filtration tool).</div><div>> >> >> Strace is one of my favorite tools in linux and want to contribute to</div><div>> >> >> the community.</div><div>> >> >>  I have looked into the mail archives about getting started and</div><div>> >> >> submitted two small patches. I have tried to understand the test</div><div>> >> >> infrastructure and will like to add some tests or fix some of the</div><div>> >> >> existing tests.</div><div>> >> >> It'll be great if someone can suggest either some tests or any other</div><div>> >> >> small bug-fix that I can work upon.</div><div>> >> >> Thanks :)</div><div>> >> ></div><div>> >> > I think write netlink socket parser is suited for you. This is a GSoC 2016</div><div>> >> > and 2017 project. The part of netfilter has not implemented yet.</div><div>> >> > I working on it, but recent I am busy. If you are interested in it, please</div><div>> >> > tell me.</div><div>> >> ></div><div>> >> Yes, definitely. I'm interested.</div><div>> >> How should I start with the project ? (Any guidance will be</div><div>> >> appreciated, meanwhile I'll try to go through your code in strace.)</div><div>> >> Can you assign me a small task in the project ?</div><div>> >> Thanks for your time. :')</div><div>> ></div><div>> > 300d9f1f: Further decode some attributes.</div><div>> > 37dfe8c7: Implement a small protocol.</div><div>> ></div><div>> > You can read these commits to get some idea.</div><div>> </div><div>> I'm unable to find the header file for kobject_uevent_types (like</div><div>> rtnetlink.h and selinux_netlink.h in case of route and selinux ).</div><div>> I'm approaching in the way similar to netlink_route and</div><div>> netlink_selinux, is this correct ?</div><div><br></div><div>NETLINK_KOBJECT_UEVENT netlink messages without a netlink message header.</div><div>You can search source code to see how to handle this.</div><div><br></div><div>$ git grep "NETLINK_KOBJECT_UEVENT"</div><div>netlink.c:      if (family == NETLINK_KOBJECT_UEVENT) {</div><div><br></div><div>If family == NETLINK_KOBJECT_UEVENT, we deocde NETLINK_KOBJECT_UEVENT directly.</div><div><br></div><div>> </div><div>> > I recommend you to decode libudev</div><div>> > netlink header (struct udev_monitor_netlink_header).</div><div>> ></div><div>> > systemd/src/libudev/libudev-monitor.c: 76</div><div>> > struct udev_monitor_netlink_header {</div><div>> >         /* "libudev" prefix to distinguish libudev and kernel messages */</div><div>> >         char prefix[8];</div><div>> >         /*</div><div>> >          * magic to protect against daemon <-> library message format mismatch</div><div>> >          * used in the kernel from socket filter rules; needs to be stored in network order</div><div>> >          */</div><div>> >         unsigned int magic;</div><div>> >         /* total length of header structure known to the sender */</div><div>> >         unsigned int header_size;</div><div>> >         /* properties string buffer */</div><div>> >         unsigned int properties_off;</div><div>> >         unsigned int properties_len;</div><div>> >         /*</div><div>> >          * hashes of primary device properties strings, to let libudev subscribers</div><div>> >          * use in-kernel socket filters; values need to be stored in network order</div><div>> >          */</div><div>> >         unsigned int filter_subsystem_hash;</div><div>> >         unsigned int filter_devtype_hash;</div><div>> >         unsigned int filter_tag_bloom_hi;</div><div>> >         unsigned int filter_tag_bloom_lo;</div><div>> > };</div><div>> </div><div>> ./tests/netlink_kobject_uevent</div><div>> sendto(3, "\0\1\2\3\4\5\6\7\10\t\n\v\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37",</div><div>> 32, MSG_DONTWAIT, NULL, 0) = -1 ECONNREFUSED (Connection refused)</div><div>> sendto(3, "=\0\1\2\3\4\5\6\7\10\t\n\v\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36"...,</div><div>> 33, MSG_DONTWAIT, NULL, 0) = -1 ECONNREFUSED (Connection refused)</div><div>> +++ exited with 0 +++</div><div>> </div><div>> This string "\0\1\2\3\4\5\6\7\10\t\n\v\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37"</div><div>>  needs to be parsed as prefix, magic, header_size, properties_off,</div><div>> properties_len, and more ( from struct udev_monitor_netlink_header).</div><div>> Is this correct, just want to make sure that I'm approaching in right</div><div>> direction ?</div><div>> Thanks for your time.</div><div><br></div><div>If the prefix is "libudev", it contain struct udev_monitor_netlink_header.</div><div><br></div><div>You can read current strace output to get some idea.</div><div><br></div><div>$ strace -e%network udevadm monitor > /dev/null # Remove your mouse</div><div>$ strace -e%network udevadm monitor -u > /dev/null # Remove your mouse</div><div>$ strace -e%network udevadm monitor -k > /dev/null # Remove your mouse</div><div><br></div><div>> </div><div>> Regards,</div><div>> Harsha Sharma</div><div>> </div><div>> > Netlink overview and its strace parsers:</div><div>> > <a href="http://blog.saruta.eu/netlink_strace.html">http://blog.saruta.eu/netlink_strace.html</a></div><div>> ></div><div>> >></div><div>> >> > More information:</div><div>> >> ></div><div>> >> > strace GSoC 2017 netlink socket parsers:</div><div>> >> > <a href="https://ppiao.github.io/2017/08/22/strace-gsoc-2017-netlink-socket-parser.html">https://ppiao.github.io/2017/08/22/strace-gsoc-2017-netlink-socket-parser.html</a></div><div>> >> ></div><div>> >> > My current work of netfilter parser:</div><div>> >> > (Need to fix.)</div><div>> >> > <a href="https://github.com/ppiao/strace">https://github.com/ppiao/strace</a></div><div>> >> ></div><div>> ></div><div><br></div><div>--</div><div>Chen Jingpiao</div></div>