ip(4) says that IP_MAX_MEMBERSHIPS is 20, but it was bumped to 4095 in rev 1.73 of netinet/in.h.
Index: ip.4 =================================================================== RCS file: /cvs/src/share/man/man4/ip.4,v retrieving revision 1.26 diff -p -u -r1.26 ip.4 --- ip.4 31 May 2007 19:19:50 -0000 1.26 +++ ip.4 13 Mar 2008 16:12:10 -0000 @@ -310,7 +310,7 @@ programs running on multihomed hosts may join the same group on more than one interface. Up to .Dv IP_MAX_MEMBERSHIPS -(currently 20) memberships may be added on a +(currently 4095) memberships may be added on a single socket. .Pp To drop a membership, use: