A mirror of Man pages
Go to file
Graham Shaw 5f343bf20b packet.7: Add sll_protocol to list of required fields for outbound packets
The manpage packet(7) currently states that:

"When you send packets it is enough to specify sll_family, sll_addr,
sll_halen, sll_ifindex."

This is incorrect: you also need to specify sll_protocol.

(The protocol specified when the socket is created is used for
filtering inbound packets, but not for constructing outbound
packets.)

I encountered this while researching a page for my website:

http://www.microhowto.info/howto/send_an_arbitrary_ethernet_frame_using_an_af_packet_socket_in_c.html

To empirically verify the behaviour I took my test code from the
above page then changed it to use different values for the third
argument to socket() and the sll_protocol field:

- socket created with ETH_P_ARP, packet sent with ETH_P_ARP:
     packet sent with EtherType of ETH_P_ARP
- socket created with ETH_P_ARP, sll_protocol==0:
     packet sent with EtherType of 0
- socket created with 0x88b5, sll_protocol==htons(ETH_P_ARP):
     packet sent with EtherType of ETH_P_ARP
- socket created with ETH_P_ARP, sll_protocol==htons(0x88b5):
     packet sent with EtherType of 0x88b5

This shows that leaving sll_protocol set to zero does not have
the desired effect and that it needs to be set to the desired
link-layer protocol.

There is code in the relevant kernel source file
(net/packet/af_packet.c) which appears to inspect the value of the
sll_protocol field and use it as the link-layer protocol number,
however I am not sufficiently familiar with this subsystem to be
fully confident of what is happening. The line in question is:

     proto   = saddr->sll_protocol;

In version 3.4 of the kernel this can be found in the functions
packet_snd and tpacket_snd. In version 2.6.26 it is in packet_sendmsg.

Below is a patch that adds sll_protocol to the list of required fields.
This may not be the whole truth, since it is not clear what role if any
sll_protocol, sll_halen or sll_addr would play when the socket type is
SOCK_RAW, however I'm confident it is more accurate than the page as it
stands at present.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-05-06 15:01:52 +02:00
man1 getent.1, fallocate.2, getrlimit.2, llseek.2, madvise.2, mount.2, poll.2, posix_fadvise.2, pread.2, stat.2, symlink.2, timer_create.2, timerfd_create.2, unshare.2, acos.3, acosh.3, asin.3, asinh.3, asprintf.3, atan.3, atan2.3, atanh.3, cabs.3, cacos.3, cacosh.3, carg.3, casin.3, casinh.3, catan.3, catanh.3, cbrt.3, ccos.3, ccosh.3, ceil.3, cexp.3, cimag.3, clog.3, conj.3, copysign.3, cos.3, cosh.3, cpow.3, cproj.3, creal.3, csin.3, csinh.3, csqrt.3, ctan.3, ctanh.3, ctime.3, erf.3, erfc.3, exec.3, exp.3, exp2.3, expm1.3, fabs.3, fdim.3, floor.3, fma.3, fmax.3, fmin.3, fmod.3, frexp.3, ftw.3, get_nprocs_conf.3, getcwd.3, gethostbyname.3, getnetent.3, getutent.3, glob.3, ilogb.3, insque.3, j0.3, ldexp.3, lgamma.3, log.3, log10.3, log1p.3, log2.3, logb.3, login.3, lrint.3, lround.3, lseek64.3, malloc.3, mbsnrtowcs.3, mbsrtowcs.3, modf.3, mq_notify.3, mq_open.3, nan.3, nextafter.3, openpty.3, perror.3, posix_memalign.3, pow.3, printf.3, qsort.3, realpath.3, remainder.3, remquo.3, rint.3, round.3, scalbln.3, scandir.3, scanf.3, setnetgrent.3, significand.3, sin.3, sinh.3, sqrt.3, strcasecmp.3, tan.3, tanh.3, tgamma.3, trunc.3, unlocked_stdio.3, updwtmp.3, wcrtomb.3, wcsnrtombs.3, wcsrtombs.3, wordexp.3, wprintf.3, y0.3, epoll.7, icmp.7, nptl.7: tstamp 2015-04-19 11:20:58 +02:00
man2 keyctl.2: srcfix: add FIXMES 2015-05-06 09:44:03 +02:00
man3 scanf.3: tfix 2015-05-06 14:53:30 +02:00
man4 tty_ioctl.4: Document TIOCGPTLCK 2015-05-01 23:11:58 +02:00
man5 proc.5: Improve description of /proc/PID/status 2015-05-05 18:35:54 +02:00
man6 getent.1, _syscall.2, acct.2, adjtimex.2, bdflush.2, brk.2, cacheflush.2, getsid.2, getxattr.2, inotify_add_watch.2, inotify_init.2, inotify_rm_watch.2, ioperm.2, ipc.2, listxattr.2, mlock.2, modify_ldt.2, mremap.2, nanosleep.2, outb.2, perf_event_open.2, ptrace.2, removexattr.2, s390_runtime_instr.2, sched_get_priority_max.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setparam.2, sched_setscheduler.2, sched_yield.2, setsid.2, setxattr.2, socketcall.2, unimplemented.2, aio_cancel.3, aio_error.3, aio_fsync.3, aio_read.3, aio_return.3, aio_suspend.3, aio_write.3, cfree.3, crypt.3, dlopen.3, encrypt.3, errno.3, fenv.3, ftime.3, ftw.3, getgrent_r.3, getpass.3, getpwent_r.3, getutent.3, hsearch.3, lio_listio.3, lockf.3, login.3, longjmp.3, perror.3, printf.3, scandirat.3, setjmp.3, strfmon.3, strtoimax.3, termios.3, ttyname.3, ualarm.3, updwtmp.3, wcstoimax.3, wordexp.3, console_ioctl.4, dsp56k.4, fd.4, hd.4, intro.4, lp.4, mem.4, null.4, ram.4, rtc.4, sk98lin.4, tty.4, ttyS.4, vcs.4, filesystems.5, group.5, host.conf.5, hosts.5, intro.5, issue.5, motd.5, networks.5, nologin.5, nsswitch.conf.5, passwd.5, proc.5, protocols.5, securetty.5, shells.5, termcap.5, ttytype.5, utmp.5, intro.6, armscii-8.7, ascii.7, bootparam.7, cp1251.7, environ.7, glob.7, intro.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, posixoptions.7, standards.7, unicode.7, utf-8.7, intro.8: s/GPLv2+_doc_full/GPLv2+_DOC_FULL/ 2013-03-10 10:57:11 +01:00
man7 packet.7: Add sll_protocol to list of required fields for outbound packets 2015-05-06 15:01:52 +02:00
man8 nscd.8: Add mention of 'services' and 'netgroup' databases 2015-05-06 10:39:44 +02:00
scripts find_repeated_words.sh: Do not process files that are redirects 2015-03-22 19:25:22 +01:00
Changes Start of man-pages-4.00: updating Changes and Changes.old 2015-04-19 11:33:05 +02:00
Changes.old Changes.old: Fixes to 3.83 changelog 2015-04-20 07:13:11 +02:00
Makefile Makefile: Add 'check-groff-warnings' target 2012-10-24 14:53:48 +02:00
README README: Explain usage of prefix when installing 2014-05-26 10:16:11 +02:00
man-pages-4.00.Announce Start of man-pages-4.00: updating .Announce and .lsm files 2015-04-19 11:33:01 +02:00
man-pages-4.00.lsm Start of man-pages-4.00: updating .Announce and .lsm files 2015-04-19 11:33:01 +02:00

README

This package contains Linux man pages for sections
2, 3, 4, 5, and 7. Some more information is given in the
`Announce' file.

Install by copying to your favourite location.
"make install" will just copy them to /usr/share/man/man[1-8].
To install to a path different from /usr use
"make install prefix=/install/path".
"make" will move the pages from this package that are older than
the already installed ones to a subdirectory `not_installed',
then remove old versions (compressed or not),
compress the pages, and copy them to /usr/share/man/man[1-8].


Note that you may have to remove preformatted pages.

Note that sometimes these pages are duplicates of pages
also distributed in other packages. This has been reported
about dlclose.3, dlerror.3, dlopen.3, dlsym.3 (found in ld.so),
about resolver.3, resolv.conf.5 (found in bind-utils),
and about passwd.5, and mailaddr.7. Be careful not to
overwrite more up-to-date versions.
Reports on further duplicates are welcome.
Formerly present and now removed duplicates:
 exports.5 (found in nfs-server-2.2*),
 fstab.5, nfs.5 (found in util-linux-2.12*),
 lilo.8, lilo.conf.5 (found in lilo-21.6*).

Copyrights: These man pages come under various copyrights.
All pages are freely distributable when the nroff source is included.

If you have corrections and additions to suggest, see
http://www.kernel.org/doc/man-pages/contributing.html