Title: error_reply() / ip_write
error_reply(ip_fd, error) simply calls the function referenced by the ip file descriptor ip_fd's (error_reply()'s first parameter) associated ip port's if_get_userdata field.
If a process opened up an ip device file (e.g., /dev/ip) directly and therefore opened up the ip file descriptor ip_fd, if_get_userdata was set to sr_get_userdata(). If this is the case, sr_get_userdata() simply sends the file system an error code or the number of bytes written.
If the udp code opened up the ip file descriptor ip_fd, if_get_userdata was set to udp_get_data(). If this is the case, udp_get_data() simply removes the packet from the up_wr_pack field and turns off the write flag for the udp file descriptor. Note that in this scenario, error (error_reply()'s second parameter) is not used.
If the icmp code opened up the ip file descriptor, if_get_userdata was set to icmp_getdata().
Note that error_reply() is somewhat of a misnomer. Even if an error did not occur, error_reply() is called.