* Raw IP socket option processing. * * IMPORTANT NOTE regarding access control: Traditionally, raw sockets could * only be created by a privileged process, and as such, socket option * operations to manage system properties on any raw socket were allowed to * take place without explicit additional access control checks. However, * raw sockets can now also be created in jail(), and therefore
| 640 | * XXX-BZ inp locking? |
| 641 | */ |
| 642 | int |
| 643 | rip_ctloutput(struct socket *so, struct sockopt *sopt) |
| 644 | { |
| 645 | struct inpcb *inp = sotoinpcb(so); |
| 646 | int error, optval; |
| 647 | |
| 648 | if (sopt->sopt_level != IPPROTO_IP) { |
| 649 | if ((sopt->sopt_level == SOL_SOCKET) && |
| 650 | (sopt->sopt_name == SO_SETFIB)) { |
| 651 | inp->inp_inc.inc_fibnum = so->so_fibnum; |
| 652 | return (0); |
| 653 | } |
| 654 | return (EINVAL); |
| 655 | } |
| 656 | |
| 657 | error = 0; |
| 658 | switch (sopt->sopt_dir) { |
| 659 | case SOPT_GET: |
| 660 | switch (sopt->sopt_name) { |
| 661 | case IP_HDRINCL: |
| 662 | optval = inp->inp_flags & INP_HDRINCL; |
| 663 | error = sooptcopyout(sopt, &optval, sizeof optval); |
| 664 | break; |
| 665 | |
| 666 | case IP_FW3: /* generic ipfw v.3 functions */ |
| 667 | case IP_FW_ADD: /* ADD actually returns the body... */ |
| 668 | case IP_FW_GET: |
| 669 | case IP_FW_TABLE_GETSIZE: |
| 670 | case IP_FW_TABLE_LIST: |
| 671 | case IP_FW_NAT_GET_CONFIG: |
| 672 | case IP_FW_NAT_GET_LOG: |
| 673 | if (V_ip_fw_ctl_ptr != NULL) |
| 674 | error = V_ip_fw_ctl_ptr(sopt); |
| 675 | else |
| 676 | error = ENOPROTOOPT; |
| 677 | break; |
| 678 | |
| 679 | case IP_DUMMYNET3: /* generic dummynet v.3 functions */ |
| 680 | case IP_DUMMYNET_GET: |
| 681 | if (ip_dn_ctl_ptr != NULL) |
| 682 | error = ip_dn_ctl_ptr(sopt); |
| 683 | else |
| 684 | error = ENOPROTOOPT; |
| 685 | break ; |
| 686 | |
| 687 | case MRT_INIT: |
| 688 | case MRT_DONE: |
| 689 | case MRT_ADD_VIF: |
| 690 | case MRT_DEL_VIF: |
| 691 | case MRT_ADD_MFC: |
| 692 | case MRT_DEL_MFC: |
| 693 | case MRT_VERSION: |
| 694 | case MRT_ASSERT: |
| 695 | case MRT_API_SUPPORT: |
| 696 | case MRT_API_CONFIG: |
| 697 | case MRT_ADD_BW_UPCALL: |
| 698 | case MRT_DEL_BW_UPCALL: |
| 699 | error = priv_check(curthread, PRIV_NETINET_MROUTE); |
nothing calls this directly
no test coverage detected