120 likes | 135 Views
This Q&A session discusses various topics related to the Computer Networking Project II, including IP layer, NAT firewall, DHCP, IP header, freeing pbufs, setsockopt, and miscellaneous considerations.
E N D
15-441 Computer Networking Project II question/answer session October 18, 2001
Handin • Send me email listing group members. • Exact format described in project handout. • Execute ‘cklog cs.cmu.edu’. • Wait for confirmation email from me. • Test read/write access. • Hand in the following files: • Source files • Makefile • Project report. • Make sure handin is correct!! Project II Q/A session: 10-18-01
Progress Report • Who has IP layer running? • NAT/Firewall? • DHCP? Project II Q/A session: 10-18-01
IP Header – ip_output() • TCP and UDP layer already allocate space for the IP header in the pbuf. • Breaks layering. • Convenient. • Makes TCP/UDP checksumming easier. • p_data member of pbuf handed over to ip_output() points to allocated IP header. • Do not modify p_len, p_data,… Project II Q/A session: 10-18-01
IP Header – ip_input() • TCP and UDP need access to the IP header. • Do not modify p_len, p_data,… when handing packet over to upper layer. Project II Q/A session: 10-18-01
Freeing pbufs() • ip_input(): • Always takes over responsibility for freeing a packet when called from link layer. • TCP and UDP receive function will free packet unless port is unreachable. • ICMP receive function always frees packets. • ICMP send function takes over responsibility for freeing packet. • Note: icmp_send() calls ip_output(). Project II Q/A session: 10-18-01
Freeing pbufs() • ip_output(): • Always takes over responsibility for freeing a packet when called from transport layer. • Needs to free packet if error condition is detected and packet is not handed over to link layer. • Link layer takes over responsibility when calling if_start(). Project II Q/A session: 10-18-01
Setsockopt() • Need mechanism to set firewalling/NAT rules in kernel from user space. • Setsockopt(int s, int level, int optname, const void *optval, int optlen); • First argument is routing socket. • Used for configuring routing table (and other). • Socket(AF_ROUTE, SOCK_RAW, 0); • Second and third argument determine kernel function to be called. • IPPROTO_IP/IP_FW_SET→ fw_setsockopt() • IPPROTO_IP/IP_NAT_SET → nat_setsockopt() Project II Q/A session: 10-18-01
Setsockopt() • Setsockopt(int s, int level, int optname, const void *optval, int optlen); • Fourth argument is pointer to arbitrary data structure. • Fifth argument denotes length of this data structure. • Setsockopt()will copy data structure from user to kernel space, call requested function, and pass it pointer to copied data structure and its length. Project II Q/A session: 10-18-01
Setsockopt() • How can we exploit Setsockopt() to configure NAT/firewalling rules in kernel? • Define data structures containing mapping or filtering rule: • struct nat_rule {…}; • struct filter_rule {…}; • Pass pointer to it (and its length) to Setsockopt(). • Setsockopt() will copy data structure to kernel space. • Infw_setsockopt()/nat_setsockopt(), cast const void pointer back to pointer to your data structure. • Parse new rule and add it to set of rules kept in kernel. Project II Q/A session: 10-18-01
Miscellaneous • Initialize routing table with a default gateway before looking up route. • rttest utility. • Keep robustness of your code in mind, e.g., • byte ordering, • checking for error/boundary conditions. • You can ignore next packet in pbuf packet queue (p_nextpkt). • Flag passed to ip_output() can be set to IP_FORWARDING (not to IP header flags!!). • Should be set when calling ip_output() from ip_forwarding(). Project II Q/A session: 10-18-01
Questions? • Read FAQ and bboard before sending email to TAs. Project II Q/A session: 10-18-01